public async Task <IActionResult> OnPostSearch() { try { if (SearchDataInputModel.DateEntered != null) { if (!ValidateDate()) { ModelState.AddModelError("CustomError", "Please check the format of your date"); SearchDataInputModel = new Msd2SearchInputModel(); } } Msd2SummarySearchResultList = _msd2SubmissionSearch.GenerateMsd2ViewModelFilteredOnSearchCriteria(SearchDataInputModel, false); await PopulateDropDowns(); if (Msd2SummarySearchResultList.Count == 0) { ModelState.AddModelError("CustomError", "No records have been found matching the above criteria"); } } catch (Exception e) { ModelState.AddModelError("CustomError", e.Message); _logger.LogError(e.Message); } TempData.Put(FindSubKey, SearchDataInputModel); return(Page()); }
public async Task <IActionResult> OnGetAsync() { try { if (TempData.NotNullOrEmpty() && TempData.Peek(FindSubKey) != null) { SearchDataInputModel = TempData.Get <Msd2SearchInputModel>(FindSubKey); TempData.Keep(FindSubKey); } else { SearchDataInputModel = new Msd2SearchInputModel(); } await PopulateDropDowns(); SuccessMessage = TempData.Get <string>("EditSuccess") ?? TempData.Get <string>("DeleteSuccess") ?? string.Empty; Msd2SummarySearchResultList = _msd2SubmissionSearch.GenerateMsd2ViewModelFilteredOnSearchCriteria(SearchDataInputModel, false); } catch (NullReferenceException) { SearchDataInputModel = new Msd2SearchInputModel(); } catch (Exception e) { ModelState.AddModelError("CustomError", "There has been an error connecting to the database"); _logger.LogError(e.Message); } return(Page()); }
public IActionResult OnGetExport(Msd2SearchInputModel searchInput) { var msd2SummarySearchResultList = _msd2SubmissionSearch.GenerateMsd2ViewModelFilteredOnSearchCriteria(searchInput, true); var byteArrayCsvData = _csvExtractor.GenerateMsd2CsvExtract(msd2SummarySearchResultList); var csvDownloadFileName = "MSD2SearchResults" + DateTime.Now.ToShortDateString() + ".csv"; return(File(byteArrayCsvData, "text/csv", csvDownloadFileName)); }
public List <Msd2SummaryViewModel> GenerateMsd2ViewModelFilteredOnSearchCriteria(Msd2SearchInputModel searchInputModel, bool resultToBeExported) { _searchFilterDictionary.Clear(); CreateMsd2SearchDictionary(searchInputModel); if (_searchFilterDictionary.Count == 0) { return(new List <Msd2SummaryViewModel>()); } CreateMsd1List(_searchFilterDictionary, MSDData.MSD2); if (_msd2Queryable == null) { return(new List <Msd2SummaryViewModel>()); } AddToMsd2SummaryViewModel(); return(_msd2SummarySearchResultList); }
private void CreateMsd2SearchDictionary(Msd2SearchInputModel searchModel) { if (!string.IsNullOrWhiteSpace(searchModel.SenderId)) { _searchFilterDictionary.Add("SenderId", searchModel.SenderId); } if (!string.IsNullOrWhiteSpace(searchModel.ReportingPort)) { _searchFilterDictionary.Add("ReportingPort", searchModel.ReportingPort); } if (!string.IsNullOrWhiteSpace(searchModel.Year)) { _searchFilterDictionary.Add("Year", searchModel.Year); } if (!string.IsNullOrWhiteSpace(searchModel.Quarter)) { _searchFilterDictionary.Add("Quarter", searchModel.Quarter); } if (!string.IsNullOrWhiteSpace(searchModel.GrossWeightInward)) { _searchFilterDictionary.Add("GrossWeightIn", searchModel.GrossWeightInward); } if (!string.IsNullOrWhiteSpace(searchModel.TotalUnitInward)) { _searchFilterDictionary.Add("TotalUnitIn", searchModel.TotalUnitInward); } if (!string.IsNullOrWhiteSpace(searchModel.PassengerVehiclesInward)) { _searchFilterDictionary.Add("PassengerVehiclesIn", searchModel.PassengerVehiclesInward); } if (!string.IsNullOrWhiteSpace(searchModel.GrossWeightOutward)) { _searchFilterDictionary.Add("GrossWeightOut", searchModel.GrossWeightOutward); } if (!string.IsNullOrWhiteSpace(searchModel.TotalUnitOutward)) { _searchFilterDictionary.Add("TotalUnitOut", searchModel.TotalUnitOutward); } if (!string.IsNullOrWhiteSpace(searchModel.PassengerVehiclesOutward)) { _searchFilterDictionary.Add("PassengerVehiclesOut", searchModel.PassengerVehiclesOutward); } if (!string.IsNullOrWhiteSpace(searchModel.DateEntered)) { _searchFilterDictionary.Add("DateEntered", searchModel.DateEntered); } if (!string.IsNullOrWhiteSpace(searchModel.LastUpdatedBy)) { _searchFilterDictionary.Add("LastUpdatedBy", searchModel.LastUpdatedBy); } if (!string.IsNullOrWhiteSpace(searchModel.FileRefId)) { _searchFilterDictionary.Add("FileRefId", searchModel.FileRefId); } if (!string.IsNullOrWhiteSpace(searchModel.Source)) { _searchFilterDictionary.Add("Source", searchModel.Source); } if (!string.IsNullOrWhiteSpace(searchModel.StatisticalPort)) { _searchFilterDictionary.Add("StatisticalPort", searchModel.StatisticalPort); } }