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.

217 lines
7.7KB

  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 SwitchBoardPurpleEnvelopsIndex
  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 SwitchBoard_PurpleEnvelopesViewModel_Class
  25. Model.Title = "Purple Envelope Kits"
  26. set Model.Kit = KitRepository.PagedPurpleEnvelopsIndexView(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/SwitchBoardPurpleEnvelopeIndex.asp"--> <%
  32. End Sub
  33. Public Sub SwitchBoardPurpleEnvelopeEditPost
  34. MVC.RequirePost
  35. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  36. dim ID : ID = Request.Form("Id")
  37. dim model : set model = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(ID)
  38. set model = Automapper.AutoMap(Request.Form, model)
  39. if Request.Form("InBoundTracking") = "on" Then
  40. model.InboundSTID = SettingsRepository.FindByName("Inbound STID")
  41. end if
  42. model.Status = "Ready to Assign Labels"
  43. 'model.Validate
  44. 'If model.Validator.HasErrors then
  45. FormCache.SerializeForm "EditKit", Request.Form
  46. ' Flash.Errors = model.Validator.Errors
  47. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  48. 'Else
  49. KitRepository.Update model
  50. FormCache.ClearForm "EditKit"
  51. Flash.Success = "Kit updated."
  52. MVC.RedirectToAction "Index"
  53. 'End If
  54. End Sub
  55. Public Sub SwitchBoardPurpleEnvelopeEdit
  56. dim id : id = Request.QueryString("Id")
  57. set Model = new SwitchBoard_ViewModel_Class
  58. set Model.Kit = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(id)
  59. set Model.Labels = InkjetRecordsRepository.Find(Array("KitId =?",id),empty)
  60. set Model.StidDropDown = SettingsRepository.GetStidDropDownRS()
  61. Model.Title = "Purple Envelopes for "
  62. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  63. %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp"--> <%
  64. End Sub
  65. Public Sub Index
  66. dim page_size : page_size = 10
  67. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  68. dim page_count, record_count
  69. set Model = new PagedIndex_ViewModel_Class
  70. Model.Title = "Tracking Kits"
  71. set Model.Kit = KitRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count)
  72. Model.CurrentPageNumber = page_num
  73. Model.PageSize = page_size
  74. Model.PageCount = page_count
  75. Model.RecordCount = record_count
  76. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  77. End Sub
  78. Public Sub Search
  79. dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
  80. dim page_size : page_size = 10
  81. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  82. dim page_count, record_count
  83. set Model = new PagedIndex_ViewModel_Class
  84. Model.Title = "Kit"
  85. set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count)
  86. Model.CurrentPageNumber = page_num
  87. Model.PageSize = page_size
  88. Model.PageCount = page_count
  89. Model.RecordCount = record_count
  90. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  91. End Sub
  92. Public Sub SwitchBoardEdit
  93. dim id : id = Request.QueryString("Id")
  94. set Model = new SwitchBoard_ViewModel_Class
  95. set Model.Kit = KitRepository.SwitchBoardEditFindById(id)
  96. set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty)
  97. Model.Title = "Kit for "
  98. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  99. %> <!--#include file="../../Views/Kit/SwitchBoardEdit.asp"--> <%
  100. End Sub
  101. Public Sub Edit
  102. dim id : id = Request.QueryString("Id")
  103. set Model = new Edit_ViewModel_Class
  104. set Model.Kit = KitRepository.FindByID(id)
  105. Model.Title = "Edit Kit"
  106. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  107. %> <!--#include file="../../Views/Kit/Edit.asp"--> <%
  108. Flash.Success = "Kit Updated."
  109. End Sub
  110. Public Sub EditPost
  111. MVC.RequirePost
  112. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  113. dim ID : ID = Request.Form("Id")
  114. dim model : set model = KitRepository.FindByID(ID)
  115. set model = Automapper.AutoMap(Request.Form, model)
  116. 'model.Validate
  117. 'If model.Validator.HasErrors then
  118. FormCache.SerializeForm "EditKit", Request.Form
  119. ' Flash.Errors = model.Validator.Errors
  120. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  121. 'Else
  122. KitRepository.Update model
  123. FormCache.ClearForm "EditKit"
  124. Flash.Success = "Kit updated."
  125. MVC.RedirectToAction "Index"
  126. 'End If
  127. End Sub
  128. Public Sub Create
  129. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  130. dim ID : ID = Request.QueryString("Id")
  131. dim model : set model = new Create_ViewModel_Class
  132. model.Title = "Create Kit "
  133. model.JCode = ID
  134. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  135. set model.Jurisdiction = ugh.pop()
  136. 'If Not form_params Is Nothing then
  137. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  138. 'Else
  139. ' set Model = new Create_ViewModel_Class
  140. 'End If
  141. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  142. %> <!--#include file="../../Views/Kit/Create.asp"--> <%
  143. End Sub
  144. Public Sub CreatePost
  145. MVC.RequirePost
  146. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  147. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  148. 'new_Kit_model.Validator.Validate
  149. 'If new_Kit_model.Validator.HasErrors then
  150. ' FormCache.SerializeForm "NewKit", Request.Form
  151. ' Flash.Errors = new_Kit_model.Validator.Errors
  152. ' MVC.RedirectToAction "Create"
  153. 'Else
  154. KitRepository.AddNew new_Kit_model
  155. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  156. ' FormCache.ClearForm "NewKit"
  157. Flash.Success = "Kit added."
  158. MVC.RedirectToAction "Index"
  159. 'End If
  160. End Sub
  161. Public Sub Delete
  162. dim id : id = Request.QueryString("Id")
  163. set Model = new Delete_ViewModel_Class
  164. set Model.Kit = KitRepository.FindByID(id)
  165. Model.Title = "Delete Kit"
  166. HTMLSecurity.SetAntiCSRFToken "KitDeleteForm"
  167. %> <!--#include file="../../Views/Kit/Delete.asp"--> <%
  168. End Sub
  169. Public Sub DeletePost
  170. MVC.RequirePost
  171. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create"
  172. dim id : id = Request.Form("Id")
  173. KitRepository.Delete id
  174. Flash.Success = "Kit deleted."
  175. MVC.RedirectToAction "Index"
  176. End Sub
  177. End Class
  178. MVC.Dispatch
  179. %>

Powered by TurnKey Linux.