예제 #1
0
        public async Task <IActionResult> AddOrganisationAsync(
            [FromBody] CreateOrganisationRequestDto createOrganisationRequestDto,
            CancellationToken token = default)
        {
            try
            {
                var validationResult = await _createOrganisationRequestDtoValidator.ValidateAsync(createOrganisationRequestDto, token);

                if (!validationResult.IsValid)
                {
                    return(new BadRequestObjectResult(validationResult.Errors.ToValidationErrors()));
                }
                var organisationServiceObject = Mapper.Map <OrganisationServiceObject>(createOrganisationRequestDto);
                var serviceResponse           = await _organisationService.AddOrganisationAsync(organisationServiceObject, token);

                return(new CreatedResult(string.Empty, Mapper.Map <CreateOrganisationResponseDto>(serviceResponse)));
            }
            catch (Exception e)
            {
                return(new BadRequestObjectResult(e));
            }
        }