public IActionResult Insert([FromBody] ApplicantWDTO model) { try { var id = service.InsertApplicant(model); var url = Url.Link("GetApplicant", new { id = id }); return(Created(url, model)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, localizer["An error occured. Please, check the log file for details."].Value)); } }
public IActionResult Update(int id, [FromBody] ApplicantWDTO model) { try { var res = service.UpdateApplicant(id, model); return(res != null?Ok(model) : NotFound()); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, localizer["An error occured. Please, check the log file for details."].Value)); } }
/// <inheritdoc /> public int InsertApplicant(ApplicantWDTO model) { try { var entity = mapper.Map <Applicant>(model); applicantRepo.Insert(entity); return(entity.Id); } catch (Exception ex) { logger.LogError("Unsuccessful applicant creation", ex); throw; } }
/// <inheritdoc /> public ApplicantWDTO UpdateApplicant(int id, ApplicantWDTO model) { try { var entity = applicantRepo.GetById(id); if (entity != null) { mapper.Map <Applicant, ApplicantWDTO>(entity, model); applicantRepo.Update(entity); return(model); } return(null); } catch (Exception ex) { logger.LogError("Unsuccessful applicant update", ex); throw; } }