<% Option Explicit %> <% Class CustomOfficeCopyJobController 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 = "CustomOfficeCopyJob" set Model.CustomOfficeCopyJob = CustomOfficeCopyJobRepository.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 = "CustomOfficeCopyJob" set Model.CustomOfficeCopyJob = CustomOfficeCopyJobRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","Jcode","%" & searchValue & "%","Precinct","%" & searchValue & "%","StartingBallotNumber","%" & searchValue & "%","Amount","%" & searchValue & "%","Status","%" & searchValue & "%","Donedate","%" & 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.CustomOfficeCopyJob = CustomOfficeCopyJobRepository.FindByID(id) Model.Title = "Edit CustomOfficeCopyJob" HTMLSecurity.SetAntiCSRFToken "CustomOfficeCopyJobEditForm" %> <% Flash.Success = "CustomOfficeCopyJob Updated." End Sub Public Sub EditPost MVC.RequirePost HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "CustomOfficeCopyJobEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) dim ID : ID = Request.Form("Id") dim model : set model = CustomOfficeCopyJobRepository.FindByID(ID) set model = Automapper.AutoMap(Request.Form, model) 'model.Validate 'If model.Validator.HasErrors then FormCache.SerializeForm "EditCustomOfficeCopyJob", Request.Form ' Flash.Errors = model.Validator.Errors ' MVC.RedirectToActionExt "Edit", Array("Id",ID) 'Else CustomOfficeCopyJobRepository.Update model FormCache.ClearForm "EditCustomOfficeCopyJob" Flash.Success = "CustomOfficeCopyJob updated." MVC.RedirectToAction "Index" 'End If End Sub Public Sub Create dim form_params : set form_params = FormCache.DeserializeForm("NewCustomOfficeCopyJob") 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 "CustomOfficeCopyJobCreateForm" %> <% End Sub Public Sub CreatePost MVC.RequirePost HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "CustomOfficeCopyJobCreateForm", Request.Form("nonce"), "Create" dim new_CustomOfficeCopyJob_model : set new_CustomOfficeCopyJob_model = Automapper.AutoMap(Request.Form, new CustomOfficeCopyJobModel_Class) 'new_CustomOfficeCopyJob_model.Validator.Validate 'If new_CustomOfficeCopyJob_model.Validator.HasErrors then ' FormCache.SerializeForm "NewCustomOfficeCopyJob", Request.Form ' Flash.Errors = new_CustomOfficeCopyJob_model.Validator.Errors ' MVC.RedirectToAction "Create" 'Else CustomOfficeCopyJobRepository.AddNew new_CustomOfficeCopyJob_model ' FormCache.ClearForm "NewCustomOfficeCopyJob" Flash.Success = "CustomOfficeCopyJob 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.CustomOfficeCopyJob = CustomOfficeCopyJobRepository.FindByID(id) Model.Title = "Delete CustomOfficeCopyJob" HTMLSecurity.SetAntiCSRFToken "CustomOfficeCopyJobDeleteForm" %> <% End Sub Public Sub DeletePost MVC.RequirePost HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "CustomOfficeCopyJobDeleteForm", Request.Form("nonce"), "Create" dim id : id = Request.Form("Id") CustomOfficeCopyJobRepository.Delete id Flash.Success = "CustomOfficeCopyJob deleted." MVC.RedirectToAction "Index" End Sub End Class MVC.Dispatch %>