Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

165 строки
5.6KB

  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/KitViewModels.asp"-->
  4. <%
  5. Class KitController
  6. Public Model
  7. Public Sub SwitchBoardIndex
  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 = "Tracking Kits"
  13. set Model.Kit = KitRepository.PagedIndexView(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/Kit/SwitchBoardIndex.asp"--> <%
  19. End Sub
  20. Public Sub Index
  21. dim page_size : page_size = 10
  22. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  23. dim page_count, record_count
  24. set Model = new PagedIndex_ViewModel_Class
  25. Model.Title = "Tracking Kits"
  26. set Model.Kit = KitRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count)
  27. Model.CurrentPageNumber = page_num
  28. Model.PageSize = page_size
  29. Model.PageCount = page_count
  30. Model.RecordCount = record_count
  31. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  32. End Sub
  33. Public Sub Search
  34. dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
  35. dim page_size : page_size = 10
  36. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  37. dim page_count, record_count
  38. set Model = new PagedIndex_ViewModel_Class
  39. Model.Title = "Kit"
  40. set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count)
  41. Model.CurrentPageNumber = page_num
  42. Model.PageSize = page_size
  43. Model.PageCount = page_count
  44. Model.RecordCount = record_count
  45. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  46. End Sub
  47. Public Sub SwitchBoardEdit
  48. dim id : id = Request.QueryString("Id")
  49. set Model = new SwitchBoard_ViewModel_Class
  50. set Model.Kit = KitRepository.SwitchBoardEditFindById(id)
  51. set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty)
  52. Model.Title = "Kit for "
  53. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  54. %> <!--#include file="../../Views/Kit/SwitchBoardEdit.asp"--> <%
  55. End Sub
  56. Public Sub Edit
  57. dim id : id = Request.QueryString("Id")
  58. set Model = new Edit_ViewModel_Class
  59. set Model.Kit = KitRepository.FindByID(id)
  60. Model.Title = "Edit Kit"
  61. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  62. %> <!--#include file="../../Views/Kit/Edit.asp"--> <%
  63. Flash.Success = "Kit Updated."
  64. End Sub
  65. Public Sub EditPost
  66. MVC.RequirePost
  67. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  68. dim ID : ID = Request.Form("Id")
  69. dim model : set model = KitRepository.FindByID(ID)
  70. set model = Automapper.AutoMap(Request.Form, model)
  71. 'model.Validate
  72. 'If model.Validator.HasErrors then
  73. FormCache.SerializeForm "EditKit", Request.Form
  74. ' Flash.Errors = model.Validator.Errors
  75. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  76. 'Else
  77. KitRepository.Update model
  78. FormCache.ClearForm "EditKit"
  79. Flash.Success = "Kit updated."
  80. MVC.RedirectToAction "Index"
  81. 'End If
  82. End Sub
  83. Public Sub Create
  84. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  85. dim ID : ID = Request.QueryString("Id")
  86. dim model : set model = new Create_ViewModel_Class
  87. model.Title = "Create Kit "
  88. model.JCode = ID
  89. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  90. set model.Jurisdiction = ugh.pop()
  91. 'If Not form_params Is Nothing then
  92. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  93. 'Else
  94. ' set Model = new Create_ViewModel_Class
  95. 'End If
  96. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  97. %> <!--#include file="../../Views/Kit/Create.asp"--> <%
  98. End Sub
  99. Public Sub CreatePost
  100. MVC.RequirePost
  101. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  102. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  103. 'new_Kit_model.Validator.Validate
  104. 'If new_Kit_model.Validator.HasErrors then
  105. ' FormCache.SerializeForm "NewKit", Request.Form
  106. ' Flash.Errors = new_Kit_model.Validator.Errors
  107. ' MVC.RedirectToAction "Create"
  108. 'Else
  109. KitRepository.AddNew new_Kit_model
  110. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  111. ' FormCache.ClearForm "NewKit"
  112. Flash.Success = "Kit added."
  113. MVC.RedirectToAction "Index"
  114. 'End If
  115. End Sub
  116. Public Sub Delete
  117. dim id : id = Request.QueryString("Id")
  118. set Model = new Delete_ViewModel_Class
  119. set Model.Kit = KitRepository.FindByID(id)
  120. Model.Title = "Delete Kit"
  121. HTMLSecurity.SetAntiCSRFToken "KitDeleteForm"
  122. %> <!--#include file="../../Views/Kit/Delete.asp"--> <%
  123. End Sub
  124. Public Sub DeletePost
  125. MVC.RequirePost
  126. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create"
  127. dim id : id = Request.Form("Id")
  128. KitRepository.Delete id
  129. Flash.Success = "Kit deleted."
  130. MVC.RedirectToAction "Index"
  131. End Sub
  132. End Class
  133. MVC.Dispatch
  134. %>

Powered by TurnKey Linux.