Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

191 рядки
6.8KB

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

Powered by TurnKey Linux.