public MediatorResponse <byte[]> GetApplicationsReceived(ApplicationsReceivedParameters parameters, string username, string ukprn) { try { var reportResult = _reportingProvider.GetApplicationsReceivedResultItems(parameters.FromDate.Date, parameters.ToDate.Date, username, ukprn); var headerBuilder = new StringBuilder(); headerBuilder.AppendLine("PROTECT,,,,,,,,,,,,,,,,,,,,,,,"); headerBuilder.AppendLine(",,,,,,,,,,,,,,,,,,,,,,,"); headerBuilder.AppendLine(",,,,,,,,,,,,,,,,,,,,,,,"); headerBuilder.AppendLine("Date,Total_Number_Of_Applications,,,,,,,,,,,,,,,,,,,,,,"); headerBuilder.Append(DateTime.Now.ToString("dd/MM/yyy HH:mm")).Append(","); headerBuilder.Append(reportResult.Count); headerBuilder.AppendLine(",,,,,,,,,,,,,,,,,,,,,,"); headerBuilder.AppendLine(",,,,,,,,,,,,,,,,,,,,,,,"); var bytes = GetCsvBytes <ApplicationsReceivedResultItem, ApplicationsReceivedResultItemClassMap>(reportResult, headerBuilder.ToString()); return(GetMediatorResponse(ReportMediatorCodes.GetApplicationsReceived.Ok, bytes)); } catch (Exception ex) { _logService.Warn(ex); return(GetMediatorResponse(ReportMediatorCodes.GetApplicationsReceived.ValidationError, new byte[0])); } }
public ActionResult ValidateApplicationsReceived(ApplicationsReceivedParameters parameters) { var response = _reportMediator.ValidateApplicationsReceivedParameters(parameters); switch (response.Code) { case ReportMediatorCodes.ValidateApplicationsReceivedParameters.Ok: return(View("ApplicationsReceived", response.ViewModel)); case ReportMediatorCodes.ValidateApplicationsReceivedParameters.ValidationError: ModelState.Clear(); response.ValidationResult.AddToModelStateWithSeverity(ModelState, string.Empty); return(View("ApplicationsReceived", response.ViewModel)); default: throw new InvalidMediatorCodeException(response.Code); } }
public ActionResult DownloadApplicationsReceived(ApplicationsReceivedParameters parameters) { var response = _reportMediator.GetApplicationsReceived(parameters, User.Identity.Name, User.GetUkprn()); return(File(response.ViewModel, "text/csv", "ApplicationsReceived.csv")); }
public MediatorResponse <ApplicationsReceivedParameters> ValidateApplicationsReceivedParameters(ApplicationsReceivedParameters parameters) { var validationResult = _reportDateRangeValidator.Validate(parameters); parameters.IsValid = validationResult.IsValid; if (!validationResult.IsValid) { return(GetMediatorResponse(ReportMediatorCodes.ValidateApplicationsReceivedParameters.ValidationError, parameters, validationResult)); } return(GetMediatorResponse(ReportMediatorCodes.ValidateApplicationsReceivedParameters.Ok, parameters, validationResult)); }