<% Option Explicit %> <% Class KitController Public Model Public Sub SwitchBoardIndex 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 = "Tracking Kits" set Model.Kit = KitRepository.PagedIndexView(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 SwitchBoardPurpleEnvelopsIndex 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 SwitchBoard_PurpleEnvelopesViewModel_Class Model.Title = "Purple Envelope Kits" set Model.Kit = KitRepository.PagedPurpleEnvelopsIndexView(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 SwitchBoardPurpleEnvelopeEditPost MVC.RequirePost HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) dim ID : ID = Request.Form("Id") dim model : set model = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(ID) set model = Automapper.AutoMap(Request.Form, model) if Request.Form("InBoundTracking") = "on" Then model.InboundSTID = SettingsRepository.FindByName("Inbound STID") end if model.Status = "Ready to Assign Labels" 'model.Validate 'If model.Validator.HasErrors then FormCache.SerializeForm "EditKit", Request.Form ' Flash.Errors = model.Validator.Errors ' MVC.RedirectToActionExt "Edit", Array("Id",ID) 'Else KitRepository.Update model FormCache.ClearForm "EditKit" Flash.Success = "Kit updated." MVC.RedirectToAction "Index" 'End If End Sub Public Sub SwitchBoardPurpleEnvelopeEdit dim id : id = Request.QueryString("Id") set Model = new SwitchBoard_ViewModel_Class set Model.Kit = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(id) set Model.Labels = InkjetRecordsRepository.Find(Array("KitId =?",id),empty) set Model.StidDropDown = SettingsRepository.GetStidDropDownRS() Model.Title = "Purple Envelopes for " HTMLSecurity.SetAntiCSRFToken "KitEditForm" %> <% End Sub 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 = "Tracking Kits" set Model.Kit = KitRepository.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 = "Kit" set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & 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 SwitchBoardEdit dim id : id = Request.QueryString("Id") set Model = new SwitchBoard_ViewModel_Class set Model.Kit = KitRepository.SwitchBoardEditFindById(id) set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty) Model.Title = "Kit for " HTMLSecurity.SetAntiCSRFToken "KitEditForm" %> <% End Sub Public Sub Edit dim id : id = Request.QueryString("Id") set Model = new Edit_ViewModel_Class set Model.Kit = KitRepository.FindByID(id) Model.Title = "Edit Kit" HTMLSecurity.SetAntiCSRFToken "KitEditForm" %> <% Flash.Success = "Kit Updated." End Sub Public Sub EditPost MVC.RequirePost HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) dim ID : ID = Request.Form("Id") dim model : set model = KitRepository.FindByID(ID) set model = Automapper.AutoMap(Request.Form, model) 'model.Validate 'If model.Validator.HasErrors then FormCache.SerializeForm "EditKit", Request.Form ' Flash.Errors = model.Validator.Errors ' MVC.RedirectToActionExt "Edit", Array("Id",ID) 'Else KitRepository.Update model FormCache.ClearForm "EditKit" Flash.Success = "Kit updated." MVC.RedirectToAction "Index" 'End If End Sub Public Sub Create dim form_params : set form_params = FormCache.DeserializeForm("NewKit") dim ID : ID = Request.QueryString("Id") dim model : set model = new Create_ViewModel_Class model.Title = "Create Kit " model.JCode = ID dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty) set model.Jurisdiction = ugh.pop() '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 "KitCreateForm" %> <% End Sub Public Sub CreatePost MVC.RequirePost HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create" dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class) 'new_Kit_model.Validator.Validate 'If new_Kit_model.Validator.HasErrors then ' FormCache.SerializeForm "NewKit", Request.Form ' Flash.Errors = new_Kit_model.Validator.Errors ' MVC.RedirectToAction "Create" 'Else KitRepository.AddNew new_Kit_model KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount") ' FormCache.ClearForm "NewKit" Flash.Success = "Kit 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.Kit = KitRepository.FindByID(id) Model.Title = "Delete Kit" HTMLSecurity.SetAntiCSRFToken "KitDeleteForm" %> <% End Sub Public Sub DeletePost MVC.RequirePost HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create" dim id : id = Request.Form("Id") KitRepository.Delete id Flash.Success = "Kit deleted." MVC.RedirectToAction "Index" End Sub End Class MVC.Dispatch %>