public async Task <ValidationResponse> Handle(UpdateEpaOrganisationStandardValidationRequest request, CancellationToken cancellationToken)
        {
            var result = _validator.ValidatorUpdateEpaOrganisationStandardRequest(new UpdateEpaOrganisationStandardRequest
            {
                OrganisationId = request.OrganisationId,
                StandardCode   = request.StandardCode,
                EffectiveTo    = request.EffectiveTo,
                EffectiveFrom  = request.EffectiveFrom,
                ContactId      = request.ContactId,
                DeliveryAreas  = request.DeliveryAreas
            });

            return(await Task.FromResult(result));
        }
Пример #2
0
        public async Task <string> Handle(UpdateEpaOrganisationStandardRequest request, CancellationToken cancellationToken)
        {
            ProcessRequestFieldsForSpecialCharacters(request);
            var validationResponse = _validator.ValidatorUpdateEpaOrganisationStandardRequest(request);

            if (!validationResponse.IsValid)
            {
                var message = validationResponse.Errors.Aggregate(string.Empty, (current, error) => current + error.ErrorMessage + "; ");
                _logger.LogError(message);
                if (validationResponse.Errors.Any(x => x.StatusCode == ValidationStatusCode.BadRequest.ToString()))
                {
                    throw new BadRequestException(message);
                }

                throw new Exception(message);
            }

            var organisationStandard = MapOrganisationStandardRequestToOrganisationStandard(request);

            return(await _registerRepository.UpdateEpaOrganisationStandard(organisationStandard, request.DeliveryAreas));
        }