public void Put(int id, [FromBody] ApplicantModel applicantModel) { _LogHelper.Information(String.Format("Put regqest 'api/applicant has come.'")); try { if (ModelState.IsValid) { Applicant applicant = _Mapper.Map <Applicant>(applicantModel); _ApplicantManager.Update(id, applicant); } } catch (Exception ex) { _LogHelper.Error(String.Format("Put regqest 'api/applicant got the followwing error: {0}", ex.ToString())); throw new ApiException(ex.Message, System.Net.HttpStatusCode.BadRequest); } }
public ActionResult Put(int id, [FromBody] Applicant applicant) { if (id != applicant.Id) { return(BadRequest()); } if (_applicantManager.Get(id) == null) { return(NotFound()); } applicant = ValidateCountry(applicant).Result; var result = _validator.Validate(applicant); if (result.IsValid) { var response = _applicantManager.Update(applicant); return(NoContent()); } return(BadRequest(result.Errors.FirstOrDefault()?.ErrorMessage)); }