<% 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.FindByID(ID) set model = Automapper.AutoMap(Request.Form, model) dim inkjetSortDirection : inkjetSortDirection = UCase(Trim(Request.Form("InkjetSortDirection") & "")) model.InboundSTID = Null If inkjetSortDirection = "ASC" Then model.JobType = "Purple Envelopes-Ascending" Else model.JobType = "Purple Envelopes" 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 AssignKitColorPost MVC.RequirePost HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "ColorAssignForm", Request.Form("nonce"), "SwitchBoardPurpleEnvelopeEdit", Array("Id", Request.Form("Id")) dim ID : ID = Request.Form("Id") If Len(Request.Form("KitColorId")) > 0 AND Request.Form("KitColorId") <> "" Then InkjetRecordsRepository.UpdateColorForKit CLng(ID), CLng(Request.Form("KitColorId")) End If Flash.Success = "Color applied to all labels in kit." MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", ID) End Sub Public Sub AssignPrecinctColorsPost MVC.RequirePost HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "ColorAssignForm", Request.Form("nonce"), "SwitchBoardPurpleEnvelopeEdit", Array("Id", Request.Form("Id")) dim ID : ID = Request.Form("Id") dim key For Each key In Request.Form If Left(key, 14) = "PrecinctColor_" Then dim precinct : precinct = Mid(key, 15) dim colorId : colorId = Request.Form(key) If Len(colorId) > 0 AND colorId <> "" Then InkjetRecordsRepository.UpdateColorForPrecinct CLng(ID), precinct, CLng(colorId) End If End If Next Flash.Success = "Precinct colors saved." MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", ID) End Sub Public Sub SwitchBoardPurpleEnvelopeEdit Flash.ShowErrorsIfPresent Flash.ShowSuccessIfPresent dim id : id = Request.QueryString("Id") set Model = new SwitchBoard_ViewModel_Class set Model.Kit = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(id) set Model.StidDropDown = SettingsRepository.GetStidDropDownRS() set Model.ColorsDropDown = ColorsRepository.GetColorsDropDownRS() set Model.Precincts = PurpleEnvelopeReportHelper().SortPrecinctColorRows(InkjetRecordsRepository.GetDistinctPrecinctsByKitId(id)) set Model.PrecinctBallotRanges = PurpleEnvelopeReportHelper().BuildBallotRangesWithMissing(InkjetRecordsRepository.GetBallotNumbersByKitId(id)) On Error Resume Next Model.PurpleEnvelopeElectionLabel = PurpleEnvelopeReportHelper().FormatElectionLabel(SettingsRepository.FindByName("Electiondate")) If Err.Number <> 0 Then Model.PurpleEnvelopeElectionLabel = "" Err.Clear End If On Error GoTo 0 Model.Title = "Purple Envelopes for " HTMLSecurity.SetAntiCSRFToken "KitEditForm" HTMLSecurity.SetAntiCSRFToken "ColorAssignForm" %> <% End Sub Public Sub PrintDeliveryPaperwork dim id : id = Trim(Request.QueryString("Id") & "") If Len(id) = 0 Or Not IsNumeric(id) Then Flash.AddError "Unable to print delivery paperwork because the kit ID is missing or invalid." MVC.RedirectToAction "SwitchBoardPurpleEnvelopsIndex" Exit Sub End If dim kitId : kitId = CLng(id) dim kitInfo On Error Resume Next set kitInfo = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(kitId) If Err.Number <> 0 Then dim loadErrDescription : loadErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Unable to load the requested kit. " & loadErrDescription MVC.RedirectToAction "SwitchBoardPurpleEnvelopsIndex" Exit Sub End If On Error GoTo 0 If UCase(Trim(kitInfo.Status & "")) <> "DONE" Then Flash.AddError "Delivery paperwork can only be printed when the kit status is Done." MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim inkjetCount : inkjetCount = 0 If IsNumeric(kitInfo.LabelCount) Then inkjetCount = CLng(kitInfo.LabelCount) End If If inkjetCount <= 0 Then Flash.AddError "Delivery paperwork cannot be generated because no labels were found for this kit." MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim appPath : appPath = Request.ServerVariables("APPL_PHYSICAL_PATH") dim labelsTemplatePath : labelsTemplatePath = appPath & "Data\Delivery_Labels.rep" dim packingSlipTemplatePath : packingSlipTemplatePath = appPath & "Data\Delivery_PackingSlip.rep" If FSO.FileExists(labelsTemplatePath) = False Then Flash.AddError "Delivery labels template was not found: Data\Delivery_Labels.rep" MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If If FSO.FileExists(packingSlipTemplatePath) = False Then Flash.AddError "Delivery packing slip template was not found: Data\Delivery_PackingSlip.rep" MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim totalBoxes : totalBoxes = Int((inkjetCount + 1099) / 1100) If totalBoxes <= 0 Then Flash.AddError "Delivery paperwork cannot be generated because no shipping boxes were calculated." MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim jurisdiction : jurisdiction = Trim(kitInfo.Jurisdiction & "") dim jCode : jCode = Trim(kitInfo.JCode & "") dim jobNumber : jobNumber = Trim(kitInfo.JobNumber & "") dim pages : set pages = new LinkedList_Class dim boxNum : boxNum = totalBoxes dim pageNum : pageNum = 1 dim page, slot, labelText Do While boxNum >= 1 set page = new DeliveryLabelPage_Class page.PageNum = pageNum For slot = 1 To 6 labelText = "" If boxNum >= 1 Then labelText = jurisdiction & vbCrLf & _ "Box " & boxNum & " of " & totalBoxes & vbCrLf & _ "Total Printed " & inkjetCount & vbCrLf & _ "Job# " & jobNumber boxNum = boxNum - 1 End If Select Case slot Case 1 : page.Label1 = labelText Case 2 : page.Label2 = labelText Case 3 : page.Label3 = labelText Case 4 : page.Label4 = labelText Case 5 : page.Label5 = labelText Case 6 : page.Label6 = labelText End Select Next pages.Push page pageNum = pageNum + 1 Loop dim exportFolder : exportFolder = ExportDirectory & jCode & "-" & jurisdiction On Error Resume Next If FSO.FolderExists(exportFolder) = False Then FSO.CreateFolder(exportFolder) End If If Err.Number <> 0 Then dim folderErrDescription : folderErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Unable to create the delivery export folder. " & folderErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim labelsBaseName : labelsBaseName = jobNumber & " - " & jurisdiction dim labelsFilename : labelsFilename = labelsBaseName & "_delivery_labels.pdf" dim packingSlipFilename : packingSlipFilename = jCode & "-" & jurisdiction & "_delivery_packing_slip.pdf" dim labelsFinalPath : labelsFinalPath = exportFolder & "\" & labelsFilename dim packingSlipFinalPath : packingSlipFinalPath = exportFolder & "\" & packingSlipFilename dim labelsTempPath : labelsTempPath = appPath & "Data\" & labelsBaseName & "_delivery_labels.tmp.pdf" dim packingSlipTempPath : packingSlipTempPath = appPath & "Data\" & jCode & "-" & jurisdiction & "_delivery_packing_slip.tmp.pdf" If FSO.FileExists(labelsTempPath) Then FSO.DeleteFile labelsTempPath If FSO.FileExists(packingSlipTempPath) Then FSO.DeleteFile packingSlipTempPath If Err.Number <> 0 Then dim tempErrDescription : tempErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Unable to clear previous temporary delivery paperwork files. " & tempErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If On Error GoTo 0 dim databaseConnectionString If dev = true Then databaseConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & appPath & "Data\webdata - Copy.mdb;" Else databaseConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;" End If On Error Resume Next KitRepository.SaveDeliveryLabelPages kitId, pages If Err.Number <> 0 Then dim stageErrDescription : stageErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Unable to stage delivery label data. " & stageErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim labelsReport : set labelsReport = Server.CreateObject("ReportMan.ReportManX") labelsReport.Filename = labelsTemplatePath labelsReport.SetDatabaseConnectionString "TRACKINGKITLABELS", databaseConnectionString labelsReport.Preview = False labelsReport.ShowProgress = False labelsReport.ShowPrintDialog = False labelsReport.SetParamValue "PBKITID", CInt(kitId) labelsReport.SaveToPdf labelsTempPath, 1 set labelsReport = Nothing If Err.Number <> 0 Then dim labelsErrDescription : labelsErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Unable to generate the delivery labels PDF. " & labelsErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If dim slipReport : set slipReport = Server.CreateObject("ReportMan.ReportManX") slipReport.Filename = packingSlipTemplatePath slipReport.SetDatabaseConnectionString "TRACKINGKITLABELS", databaseConnectionString slipReport.Preview = False slipReport.ShowProgress = False slipReport.ShowPrintDialog = False slipReport.SetParamValue "PBKITID", CInt(kitId) slipReport.SaveToPdf packingSlipTempPath, 1 set slipReport = Nothing If Err.Number <> 0 Then dim slipErrDescription : slipErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Unable to generate the delivery packing slip PDF. " & slipErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If If FSO.FileExists(labelsFinalPath) Then FSO.DeleteFile labelsFinalPath If FSO.FileExists(packingSlipFinalPath) Then FSO.DeleteFile packingSlipFinalPath FSO.MoveFile labelsTempPath, labelsFinalPath FSO.MoveFile packingSlipTempPath, packingSlipFinalPath If Err.Number <> 0 Then dim moveErrDescription : moveErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Delivery paperwork PDFs were generated but could not be moved into the export folder. " & moveErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If On Error GoTo 0 On Error Resume Next KitRepository.DeleteDeliveryLabelPages kitId If Err.Number <> 0 Then dim cleanupErrDescription : cleanupErrDescription = Err.Description Err.Clear On Error GoTo 0 Flash.AddError "Delivery paperwork PDFs were generated, but staging cleanup failed. " & cleanupErrDescription MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) Exit Sub End If On Error GoTo 0 Flash.Success = "Delivery paperwork generated successfully." MVC.RedirectToActionExt "SwitchBoardPurpleEnvelopeEdit", Array("Id", kitId) 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 Flash.ShowSuccessIfPresent 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 ExportTrackingLabels(id) dim KitInfo : Set KitInfo = KitRepository.FindByID(id) dim JurisdictionInfo : Set JurisdictionInfo = JurisdictionRepository.FindByJCode(KitInfo.Jcode) ReportManager.Filename = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\Label_Report.rep" if dev = true Then ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata - Copy.mdb;" else ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;" End If ReportManager.Preview = false ReportManager.ShowProgress = false ReportManager.ShowPrintDialog = false ReportManager.SetParamValue "PBKITID", CInt(id) if FSO.FolderExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) = False then FSO.CreateFolder(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) end if dim labelsJobFileName : labelsJobFileName = KitInfo.JobNumber & " - " & JurisdictionInfo.Name & "_labels.pdf" dim labelsJobTempFileName : labelsJobTempFileName = KitInfo.JobNumber & " - " & JurisdictionInfo.Name & " Labels.pdf" if FSO.FileExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & labelsJobFileName) then FSO.DeleteFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & labelsJobFileName) end if ReportManager.SaveToPdf Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Data\" & labelsJobTempFileName,1 FSO.MoveFile Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Data\" & labelsJobTempFileName , ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & labelsJobFileName End Sub Public Sub ExportSnailWorksTracking(id) dim KitInfo : Set KitInfo = KitRepository.FindByID(id) dim JurisdictionInfo : Set JurisdictionInfo = JurisdictionRepository.FindByJCode(KitInfo.Jcode) if FSO.FolderExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) = False then FSO.CreateFolder(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) end if if FSO.FileExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv") then FSO.DeleteFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv") end if dim export: set export = SnailWorksRepository.GetSnailWorksExportById(id) if export.DetailRecords.Count > 0 Then dim objExportFile: Set objExportFile = FSO.CreateTextFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv",2) With objExportFile .Write """" & export.Header.RecordType & """," .Write """" & export.Header.Version & """," .Write """" & export.Header.UserId & """," .Write """" & export.Header.ClientName & """," .Write """" & export.Header.ParentClientName & """," .Write """" & export.Header.JobName & """," .Write """" & export.Header.JobDescription & """," .Write """" & export.Header.SplitName & """," .Write """" & export.Header.SplitDescription & """," .Write """" & export.Header.PieceType & """," .Write """" & export.Header.MailDate & """," .Write """" & export.Header.UploadType & """," .Write """" & export.Header.TrackedQuanity & """," .Write """" & export.Header.PiecesMailed & """," .Write """" & export.Header.TargetInHomeDateStart & """," .Write """" & export.Header.TargetInHomeDateEnd & """," .Write """" & export.Header.ConfirmationEmail & """," .Write """" & export.Header.JobId & """," .Write """" & export.Header.SplitId & """," .Write """" & export.Header.TypeOfTracking & """," .Write """" & export.Header.ReturnedPostalRoutingCode & """," .Write """" & export.Header.ReportId1 & """," .Write """" & export.Header.Report1Email & """," .Write """" & export.Header.ReportId2 & """," .Write """" & export.Header.Report2Email & """," .Write """" & export.Header.INFOONLY & """" .Write vbCrLf dim it:set it = export.DetailRecords.Iterator dim records while it.HasNext set records = it.GetNext() .Write """" & records.RecordType & """," .Write """" & records.CustomerUniqueIdentifier & """," .Write """" & records.IMB & """," .Write """" & records.Greeting & """," .Write """" & records.FirstName & """," .Write """" & records.MI & """," .Write """" & records.LastName & """," .Write """" & records.Suffix & """," .Write """" & records.FullName & """," .Write """" & records.Company & """," .Write """" & records.Title & """," .Write """" & records.Address1 & """," .Write """" & records.Address2 & """," .Write """" & records.City & """," .Write """" & records.State & """," .Write """" & records.Zip & """," .Write """" & records.UserDefined1 & """," .Write """" & records.UserDefined2 & """," .Write """" & records.UserDefined3 & """," .Write """" & records.UserDefinedIdentifier4 & """," .Write """" & records.UserDefinedIdentifier5 & """," .Write """" & records.SeedIndicator & """," .Write """" & records.InductionPoint & """," .Write """" & records.InductionDate & """," .Write """" & records.InBoundIMB & """," .Write """" & records.IMCB & """," .Write """" & records.IMTB & """" & vbCRLF Wend End With End If 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 originalModel : set originalModel = KitRepository.FindByID(ID) dim model : set model = KitRepository.FindByID(ID) set model = Automapper.AutoMap(Request.Form, model) ' Handle date fields - if empty string, preserve original value or set to Null If Len(Trim(model.CreatedOn & "")) = 0 Then model.CreatedOn = originalModel.CreatedOn End If If Len(Trim(model.LabelsPrinted & "")) = 0 Then model.LabelsPrinted = Null End If If Len(Trim(model.ExportedToSnailWorks & "")) = 0 Then model.ExportedToSnailWorks = Null End If ' Handle boolean/numeric fields - convert "True"/"False" strings to proper numeric values If UCase(Trim(model.InkJetJob & "")) = "TRUE" Then model.InkJetJob = -1 ElseIf UCase(Trim(model.InkJetJob & "")) = "FALSE" Then model.InkJetJob = 0 ElseIf Len(Trim(model.InkJetJob & "")) = 0 Then model.InkJetJob = 0 End If If UCase(Trim(model.Cass & "")) = "TRUE" Then model.Cass = -1 ElseIf UCase(Trim(model.Cass & "")) = "FALSE" Then model.Cass = 0 ElseIf Len(Trim(model.Cass & "")) = 0 Then model.Cass = 0 End If ' Handle numeric fields - if empty string, set to 0 or Null If Len(Trim(model.OfficeCopiesAmount & "")) = 0 Then model.OfficeCopiesAmount = 0 End If ' Handle STID fields - if empty string, set to Null If Len(Trim(model.OutboundSTID & "")) = 0 Then model.OutboundSTID = Null End If If Len(Trim(model.InboundSTID & "")) = 0 Then model.InboundSTID = Null End If '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 CreateTrackingKit 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 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" ExportTrackingLabels(new_Kit_model.ID) ExportSnailWorksTracking(new_Kit_model.ID) Flash.Success = "Kit added." MVC.RedirectToAction "Index" 'End If End Sub Public Sub CreateTrackingKitPost 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 %>