<% Option Explicit %> <% Class InkjetRecordsController Public Model Public Sub Index dim page_size : page_size = 10 dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) dim page_count, record_count set Model = new PagedIndex_ViewModel_Class Model.Title = "InkjetRecords" set Model.InkjetRecords = InkjetRecordsRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count) Model.CurrentPageNumber = page_num Model.PageSize = page_size Model.PageCount = page_count Model.RecordCount = record_count %> <% End Sub Public Sub Search dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) dim page_size : page_size = 10 dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) dim page_count, record_count set Model = new PagedIndex_ViewModel_Class Model.Title = "InkjetRecords" 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) Model.CurrentPageNumber = page_num Model.PageSize = page_size Model.PageCount = page_count Model.RecordCount = record_count %> <% End Sub Public Sub Edit dim id : id = Request.QueryString("Id") set Model = new Edit_ViewModel_Class set Model.InkjetRecords = InkjetRecordsRepository.FindByID(id) Model.Title = "Edit InkjetRecords" HTMLSecurity.SetAntiCSRFToken "InkjetRecordsEditForm" %> <% Flash.Success = "InkjetRecords Updated." End Sub Public Sub EditPost MVC.RequirePost HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "InkjetRecordsEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) dim ID : ID = Request.Form("Id") dim model : set model = InkjetRecordsRepository.FindByID(ID) set model = Automapper.AutoMap(Request.Form, model) 'model.Validate 'If model.Validator.HasErrors then FormCache.SerializeForm "EditInkjetRecords", Request.Form ' Flash.Errors = model.Validator.Errors ' MVC.RedirectToActionExt "Edit", Array("Id",ID) 'Else InkjetRecordsRepository.Update model FormCache.ClearForm "EditInkjetRecords" Flash.Success = "InkjetRecords updated." MVC.RedirectToAction "Index" 'End If End Sub Public Sub Create dim form_params : set form_params = FormCache.DeserializeForm("NewInkjetRecords") If Not form_params Is Nothing then set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) Else set Model = new Create_ViewModel_Class End If HTMLSecurity.SetAntiCSRFToken "InkjetRecordsCreateForm" %> <% End Sub Public Sub CreatePost MVC.RequirePost HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "InkjetRecordsCreateForm", Request.Form("nonce"), "Create" dim new_InkjetRecords_model : set new_InkjetRecords_model = Automapper.AutoMap(Request.Form, new InkjetRecordsModel_Class) 'new_InkjetRecords_model.Validator.Validate 'If new_InkjetRecords_model.Validator.HasErrors then ' FormCache.SerializeForm "NewInkjetRecords", Request.Form ' Flash.Errors = new_InkjetRecords_model.Validator.Errors ' MVC.RedirectToAction "Create" 'Else InkjetRecordsRepository.AddNew new_InkjetRecords_model ' FormCache.ClearForm "NewInkjetRecords" Flash.Success = "InkjetRecords added." MVC.RedirectToAction "Index" 'End If End Sub Public Sub Delete dim id : id = Request.QueryString("Id") set Model = new Delete_ViewModel_Class set Model.InkjetRecords = InkjetRecordsRepository.FindByID(id) Model.Title = "Delete InkjetRecords" HTMLSecurity.SetAntiCSRFToken "InkjetRecordsDeleteForm" %> <% End Sub Public Sub DeletePost MVC.RequirePost HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "InkjetRecordsDeleteForm", Request.Form("nonce"), "Create" dim id : id = Request.Form("Id") InkjetRecordsRepository.Delete id Flash.Success = "InkjetRecords deleted." MVC.RedirectToAction "Index" End Sub End Class MVC.Dispatch %>