public async Task <IActionResult> CreateGenderAsync( [FromBody] AddGenderRequestDto addGenderRequestDto, CancellationToken token = default) { try { var validationResult = await _addGenderRequestValidator.ValidateAsync(addGenderRequestDto, token); if (!validationResult.IsValid) { return(new BadRequestObjectResult(validationResult.Errors.ToValidationErrors())); } var genderServiceObject = Mapper.Map <GenderServiceObject>(addGenderRequestDto); var serviceResult = await _genderService.CreateGenderAsync(genderServiceObject, token); return(new CreatedResult(string.Empty, Mapper.Map <AddGenderResponseDto>(serviceResult))); } catch (BadRequestException e) { return(new BadRequestObjectResult(e.Error)); } }