public ActionResult Put(int id, [FromBody, SwaggerRequestBody(_description4swaggerUpdateApplicant, Required = true)] Applicant applicant) { try { var updateSuccessful = _applicantManager.UpdateApplicant(id, applicant); if (updateSuccessful) { _logger.LogInformation($"The applicant with ID: {applicant.ID} updated successfully!"); return(Ok()); } else { _logger.LogWarning($"The applicant with ID: {applicant.ID} has not been found in the database!"); return(NotFound()); } } catch (Exception) { _logger.LogError($"An error occurred while trying to update the applicant with ID: {applicant.ID} Nothing has been changed!"); } return(BadRequest()); }
public ActionResult UpdateApplicant(int id, [FromBody] ApplicantViewModel model) { _logger.LogInformation("Accept request to update applicant info"); var errors = _manager.HandleErrors(model); if (errors.Count > 0) { return(BadRequest(errors)); } var result = _manager.UpdateApplicant(id, model); if (result == ReturnCode.Failed) { return(StatusCode(500)); } else if (result == ReturnCode.NotFound) { return(NotFound()); } return(StatusCode(201)); }