public ReportValidationForm(ReportValidator validator) { if (validator == null) throw new ArgumentNullException(); _validator = validator; InitializeComponent(); InitControls(); }
private bool ValidateDataReport() { ReportValidator reportValidator = new ReportValidator(); FluentValidation.Results.ValidationResult dataValidationResult = reportValidator.Validate(report); IList <ValidationFailure> validationFailures = dataValidationResult.Errors; UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures); userFeedback.ShowFeedback(); return(dataValidationResult.IsValid); }
public async Task BuildReportAsync(string appKey, string signatureProvidedByTheClient, string remoteAddress, byte[] reportBody) { Guid tempKey; if (!Guid.TryParse(appKey, out tempKey)) { _logger.Warn("Incorrect appKeyFormat: " + appKey + " from " + remoteAddress); throw new HttpException(400, "AppKey must be a valid GUID which '" + appKey + "' is not."); } var application = await GetAppAsync(appKey); if (application == null) { _logger.Warn("Unknown appKey: " + appKey + " from " + remoteAddress); throw new HttpException(400, "AppKey was not found in the database. Key '" + appKey + "'."); } if (!ReportValidator.ValidateBody(application.SharedSecret, signatureProvidedByTheClient, reportBody)) { await StoreInvalidReportAsync(appKey, signatureProvidedByTheClient, remoteAddress, reportBody); throw new HttpException(403, "You either specified the wrong SharedSecret, or someone tampered with the data."); } var report = DeserializeBody(reportBody); //fix malconfigured clients if (report.CreatedAtUtc > DateTime.UtcNow) { report.CreatedAtUtc = DateTime.UtcNow; } var internalDto = new ReceivedReportDTO { ApplicationId = application.Id, RemoteAddress = remoteAddress, ContextCollections = report.ContextCollections.Select(ConvertCollection).ToArray(), CreatedAtUtc = report.CreatedAtUtc, DateReceivedUtc = DateTime.UtcNow, Exception = ConvertException(report.Exception), ReportId = report.ReportId, ReportVersion = report.ReportVersion }; await StoreReportAsync(internalDto); }
public ReportDto Update(ReportDto reportDto) { var validator = new ReportValidator(); validator.ValidateAndThrow(reportDto); var entity = new Report(); _mapper.Map(reportDto, entity); entity.StatusId = 1; entity.UpdateDate = System.DateTime.UtcNow; _unitOfWork.ReportRepository.Update(entity); _unitOfWork.Save(); _mapper.Map(entity, reportDto); return(reportDto); }
public IActionResult GetSearchedReports(ReportSearchDTO dto) { try { ReportValidator.Validate(dto); } catch (Exception e) { return(BadRequest(e.Message)); } List <Report> reports = _reportSearchService.GetSearchedReports(dto.Doctor, dto.startDate, dto.endDate, dto.type); List <ReportDTO> reportDTOs = ReportMapper.ListExaminationSurgeryToReport(reports); return(Ok(reportDTOs)); }
public async Task <ReportDto> Insert(ReportDto reportDto) { var validator = new ReportValidator(); validator.ValidateAndThrow(reportDto); var entity = new Report(); _mapper.Map(reportDto, entity); entity.CreateDate = System.DateTime.UtcNow; entity.UpdateDate = System.DateTime.UtcNow; entity.StatusId = 1; await _unitOfWork.ReportRepository.Insert(entity); await _unitOfWork.SaveAsync(); _mapper.Map(entity, reportDto); return(reportDto); }
public ReportController() { _excelService = new ExcelService(); _reportValidator = new ReportValidator(); }
public ReportValidatorTests() { _validator = new ReportValidator(); }