Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

130 linhas
5.5KB

  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/InkjetRecordsViewModels.asp"-->
  4. <%
  5. Class InkjetRecordsController
  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 = "InkjetRecords"
  13. set Model.InkjetRecords = InkjetRecordsRepository.FindPaged(empty, "ID", 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/InkjetRecords/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 = "InkjetRecords"
  27. set Model.InkjetRecords = InkjetRecordsRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","KitID","%" & searchValue & "%","VOTERID","%" & searchValue & "%","LASTNAME","%" & searchValue & "%","FIRSTNAME","%" & searchValue & "%","MIDDLENAME","%" & searchValue & "%","SUFFIX","%" & searchValue & "%","PRECINCT","%" & searchValue & "%","ADDRESS1","%" & searchValue & "%","ADDRESS2","%" & searchValue & "%","ADDRESS3","%" & searchValue & "%","ADDRESS4","%" & searchValue & "%","ADDRESS5","%" & searchValue & "%","APPSENT","%" & searchValue & "%","APPRETURNED","%" & searchValue & "%","BALSENT","%" & searchValue & "%","BALRETURNED","%" & searchValue & "%","CountingBoard","%" & searchValue & "%","UOCAVASTATUS","%" & searchValue & "%","EMAILADDRESS","%" & searchValue & "%","PHONENUMBER","%" & searchValue & "%","BALLOT_NUMBER","%" & searchValue & "%","CassADDRESS1","%" & searchValue & "%","CassADDRESS2","%" & searchValue & "%","CassADDRESS3","%" & searchValue & "%","CassADDRESS4","%" & searchValue & "%","CassADDRESS5","%" & searchValue & "%"),"ID", 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/InkjetRecords/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.InkjetRecords = InkjetRecordsRepository.FindByID(id)
  38. Model.Title = "Edit InkjetRecords"
  39. HTMLSecurity.SetAntiCSRFToken "InkjetRecordsEditForm"
  40. %> <!--#include file="../../Views/InkjetRecords/Edit.asp"--> <%
  41. Flash.Success = "InkjetRecords Updated."
  42. End Sub
  43. Public Sub EditPost
  44. MVC.RequirePost
  45. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "InkjetRecordsEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  46. dim ID : ID = Request.Form("Id")
  47. dim model : set model = InkjetRecordsRepository.FindByID(ID)
  48. set model = Automapper.AutoMap(Request.Form, model)
  49. 'model.Validate
  50. 'If model.Validator.HasErrors then
  51. FormCache.SerializeForm "EditInkjetRecords", Request.Form
  52. ' Flash.Errors = model.Validator.Errors
  53. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  54. 'Else
  55. InkjetRecordsRepository.Update model
  56. FormCache.ClearForm "EditInkjetRecords"
  57. Flash.Success = "InkjetRecords updated."
  58. MVC.RedirectToAction "Index"
  59. 'End If
  60. End Sub
  61. Public Sub Create
  62. dim form_params : set form_params = FormCache.DeserializeForm("NewInkjetRecords")
  63. If Not form_params Is Nothing then
  64. set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  65. Else
  66. set Model = new Create_ViewModel_Class
  67. End If
  68. HTMLSecurity.SetAntiCSRFToken "InkjetRecordsCreateForm"
  69. %> <!--#include file="../../Views/InkjetRecords/Create.asp"--> <%
  70. End Sub
  71. Public Sub CreatePost
  72. MVC.RequirePost
  73. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "InkjetRecordsCreateForm", Request.Form("nonce"), "Create"
  74. dim new_InkjetRecords_model : set new_InkjetRecords_model = Automapper.AutoMap(Request.Form, new InkjetRecordsModel_Class)
  75. 'new_InkjetRecords_model.Validator.Validate
  76. 'If new_InkjetRecords_model.Validator.HasErrors then
  77. ' FormCache.SerializeForm "NewInkjetRecords", Request.Form
  78. ' Flash.Errors = new_InkjetRecords_model.Validator.Errors
  79. ' MVC.RedirectToAction "Create"
  80. 'Else
  81. InkjetRecordsRepository.AddNew new_InkjetRecords_model
  82. ' FormCache.ClearForm "NewInkjetRecords"
  83. Flash.Success = "InkjetRecords added."
  84. MVC.RedirectToAction "Index"
  85. 'End If
  86. End Sub
  87. Public Sub Delete
  88. dim id : id = Request.QueryString("Id")
  89. set Model = new Delete_ViewModel_Class
  90. set Model.InkjetRecords = InkjetRecordsRepository.FindByID(id)
  91. Model.Title = "Delete InkjetRecords"
  92. HTMLSecurity.SetAntiCSRFToken "InkjetRecordsDeleteForm"
  93. %> <!--#include file="../../Views/InkjetRecords/Delete.asp"--> <%
  94. End Sub
  95. Public Sub DeletePost
  96. MVC.RequirePost
  97. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "InkjetRecordsDeleteForm", Request.Form("nonce"), "Create"
  98. dim id : id = Request.Form("Id")
  99. InkjetRecordsRepository.Delete id
  100. Flash.Success = "InkjetRecords deleted."
  101. MVC.RedirectToAction "Index"
  102. End Sub
  103. End Class
  104. MVC.Dispatch
  105. %>

Powered by TurnKey Linux.