public IActionResult PostWithHeartUltrasound(int id, [FromForm] CommonUltrasoundView commonUltrasound) { try { if (id == 0) { return(BadRequest("id is zero")); } if (commonUltrasound == null) { return(BadRequest("Owner object is null")); } if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } _injuriesDiseasesRepository.InsertCommonUltrasound(id, commonUltrasound.ViewToEntity()); return(Ok()); } catch (Exception ex) { return(StatusCode(500, string.Format("Internal server error. Message error: {0}", ex.Message))); } }
public static CommonUltrasound ViewToEntity(this CommonUltrasoundView view) { if (view != null) { return(new CommonUltrasound { Id = view.Id, Info = view.Info, InjuriesDiseasesId = view.InjuriesDiseasesId }); } return(null); }