You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JurisdictionController.asp 5.6KB

преди 8 месеца
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/JurisdictionViewModels.asp"-->
  4. <%
  5. Class JurisdictionController
  6. Public Model
  7. Public Sub Index
  8. dim page_size : page_size = 10
  9. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  10. dim page_count, record_count
  11. set Model = new PagedIndex_ViewModel_Class
  12. Model.Title = "Jurisdiction"
  13. set Model.Jurisdiction = JurisdictionRepository.FindPaged(empty, "JCode", page_size, page_num, page_count, record_count)
  14. Model.CurrentPageNumber = page_num
  15. Model.PageSize = page_size
  16. Model.PageCount = page_count
  17. Model.RecordCount = record_count
  18. %> <!--#include file="../../Views/Jurisdiction/Index.asp"--> <%
  19. End Sub
  20. Public Sub Search
  21. dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
  22. dim page_size : page_size = 10
  23. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  24. dim page_count, record_count
  25. set Model = new PagedIndex_ViewModel_Class
  26. Model.Title = "Jurisdiction"
  27. set Model.Jurisdiction = JurisdictionRepository.SearchTablePaged(Array("JCode","%" & searchValue & "%","Name","%" & searchValue & "%","Mailing_Address","%" & searchValue & "%","CSZ","%" & searchValue & "%","IMB","%" & searchValue & "%","IMB_Digits","%" & searchValue & "%"),"JCode", page_size, page_num, page_count, record_count)
  28. Model.CurrentPageNumber = page_num
  29. Model.PageSize = page_size
  30. Model.PageCount = page_count
  31. Model.RecordCount = record_count
  32. %> <!--#include file="../../Views/Jurisdiction/Index.asp"--> <%
  33. End Sub
  34. Public Sub Edit
  35. dim id : id = Request.QueryString("Id")
  36. set Model = new Edit_ViewModel_Class
  37. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  38. set Model.Contacts = ContactsRepository.Find(Array("JURISCODE = ?",id),empty)
  39. Model.Title = "Edit Jurisdiction"
  40. HTMLSecurity.SetAntiCSRFToken "JurisdictionEditForm"
  41. %> <!--#include file="../../Views/Jurisdiction/Edit.asp"--> <%
  42. Flash.Success = "Jurisdiction Updated."
  43. End Sub
  44. Public Sub EditPost
  45. MVC.RequirePost
  46. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "JurisdictionEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  47. dim JCode : JCode = Request.Form("Id")
  48. dim model : set model = JurisdictionRepository.FindByJCode(JCode)
  49. set model = Automapper.AutoMap(Request.Form, model)
  50. 'model.Validate
  51. 'If model.Validator.HasErrors then
  52. FormCache.SerializeForm "EditJurisdiction", Request.Form
  53. ' Flash.Errors = model.Validator.Errors
  54. ' MVC.RedirectToActionExt "Edit", Array("Id",JCode)
  55. 'Else
  56. JurisdictionRepository.Update model
  57. FormCache.ClearForm "EditJurisdiction"
  58. Flash.Success = "Jurisdiction updated."
  59. MVC.RedirectToAction "Index"
  60. 'End If
  61. End Sub
  62. Public Sub Create
  63. dim form_params : set form_params = FormCache.DeserializeForm("NewJurisdiction")
  64. If Not form_params Is Nothing then
  65. set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  66. Else
  67. set Model = new Create_ViewModel_Class
  68. End If
  69. HTMLSecurity.SetAntiCSRFToken "JurisdictionCreateForm"
  70. %> <!--#include file="../../Views/Jurisdiction/Create.asp"--> <%
  71. End Sub
  72. Public Sub CreatePost
  73. MVC.RequirePost
  74. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "JurisdictionCreateForm", Request.Form("nonce"), "Create"
  75. dim new_Jurisdiction_model : set new_Jurisdiction_model = Automapper.AutoMap(Request.Form, new JurisdictionModel_Class)
  76. 'new_Jurisdiction_model.Validator.Validate
  77. 'If new_Jurisdiction_model.Validator.HasErrors then
  78. ' FormCache.SerializeForm "NewJurisdiction", Request.Form
  79. ' Flash.Errors = new_Jurisdiction_model.Validator.Errors
  80. ' MVC.RedirectToAction "Create"
  81. 'Else
  82. JurisdictionRepository.AddNew new_Jurisdiction_model
  83. ' FormCache.ClearForm "NewJurisdiction"
  84. Flash.Success = "Jurisdiction added."
  85. MVC.RedirectToAction "Index"
  86. 'End If
  87. End Sub
  88. Public Sub Delete
  89. dim id : id = Request.QueryString("Id")
  90. set Model = new Delete_ViewModel_Class
  91. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  92. Model.Title = "Delete Jurisdiction"
  93. HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm"
  94. %> <!--#include file="../../Views/Jurisdiction/Delete.asp"--> <%
  95. End Sub
  96. Public Sub DeletePost
  97. MVC.RequirePost
  98. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "JurisdictionDeleteForm", Request.Form("nonce"), "Create"
  99. dim id : id = Request.Form("Id")
  100. JurisdictionRepository.Delete id
  101. Flash.Success = "Jurisdiction deleted."
  102. MVC.RedirectToAction "Index"
  103. End Sub
  104. Public Sub Createkit
  105. dim id : id = Request.QueryString("Id")
  106. set Model = new Delete_ViewModel_Class
  107. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  108. Model.Title = "Create Kit"
  109. HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm"
  110. %> <!--#include file="../../Views/Jurisdiction/createkit.asp"--> <%
  111. End sub
  112. Public Sub CreateKitPost
  113. MVC.RequirePost
  114. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "CreateKitForm", Request.Form("nonce"), "Index"
  115. dim id : id = Request.QueryString("Id")
  116. set Model = new Delete_ViewModel_Class
  117. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  118. Model.Title = "Create Kit"
  119. HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm"
  120. %> <!--#include file="../../Views/Jurisdiction/createkit.asp"--> <%
  121. End sub
  122. End Class
  123. MVC.Dispatch
  124. %>

Powered by TurnKey Linux.