public IActionResult PutMedicalTransaction([FromRoute] int id, [FromBody] MedicalTransaction medicalTransaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != medicalTransaction.ID) { return(BadRequest()); } _medicalService.Update(medicalTransaction); try { _medicalService.Save(); } catch (DbUpdateConcurrencyException) { if (!MedicalTransactionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Put(int id, [FromBody] Medical medical) { try { VerifyUser(); _validateService.Validate(medical); Medical medicalToUpdate = await _medicalService.GetSingleById(id); await _medicalService.Update(medicalToUpdate, medical); return(NoContent()); } catch (ServiceValidationExeption e) { var result = new ResultFormatter(API_VERSION, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE) .Fail(e); return(BadRequest(result)); } catch (Exception e) { var result = new ResultFormatter(API_VERSION, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, result)); } }