public async Task <ActionResult> Update([FromRoute] int id, [FromBody] UpdateApplicantCommandDto applicantDto) { try { await _applicantService.UpdateApplicant(applicantDto.ToUpdateApplicantCommand(id)); return(Ok()); } catch (DomainException ex) { var result = ResultDto <int> .CreateFailedResult( ex.InnerExceptions.Select(x => x.Message)); return(BadRequest(result)); } catch (Exception ex) { _logger.LogError(ex, "Error On Updating applicant: data: {@applicantDto} Id: {Id}", applicantDto, id); return(StatusCode(500, "Something went wrong on server side")); } }
public async Task <IActionResult> Create([FromBody] CreateApplicantCommandDto applicantDto) { try { var result = await _applicantService.CreateApplicant(applicantDto.ToCreateApplicantCommand()); return(Created(Request.Path, ResultDto <int> .CreateSuccessfulResult(result))); } catch (DomainException ex) { var result = ResultDto <int> .CreateFailedResult( ex.InnerExceptions.Select(x => x.Message)); return(BadRequest(result)); } catch (Exception ex) { _logger.LogError(ex, "Error On creating new applicant: data: {@applicantDto}", applicantDto); return(StatusCode(500, "Something went wrong on server side")); } }