public IActionResult UpdateThreeObjects(string personId, ThreeObjectsModel threeObjectsModel) { try { if (threeObjectsModel == null) { return(BadRequest("Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(BadRequest(errors)); } threeObjectsModel.personModel.personId = personId; threeObjectsModel.approvalModel.approvalPersonId = personId; threeObjectsModel.vehicleModel.vehicleOwnerId = personId; ThreeObjectsModel updatedThreeObjects = threeObjectsRepository.UpdateThreeObjects(threeObjectsModel); return(Ok(updatedThreeObjects)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(StatusCode(StatusCodes.Status500InternalServerError, errors)); } }
public HttpResponseMessage UpdateThreeObjects(string personId, ThreeObjectsModel threeObjectsModel) { try { if (threeObjectsModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } threeObjectsModel.personModel.personId = personId; threeObjectsModel.approvalModel.approvalPersonId = personId; threeObjectsModel.vehicleModel.vehicleOwnerId = personId; ThreeObjectsModel updatedThreeObjects = threeObjectsRepository.UpdateThreeObjects(threeObjectsModel); return(Request.CreateResponse(HttpStatusCode.OK, updatedThreeObjects)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public HttpResponseMessage UpdateThreeObjects(string updateByPersonId, ThreeObjectsModel threeObjectsModel) { try { threeObjectsModel.personModel.personId = updateByPersonId; threeObjectsModel.approvalModel.approvalPersonId = updateByPersonId; threeObjectsModel.vehicleModel.vehicleOwnerId = updateByPersonId; HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(threeObjectsRepository.UpdateThreeObjects(threeObjectsModel))) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }