public async Task UloadFile(InjuriesDiseasesView injuriesDiseases) { if (injuriesDiseases.MRIs != null) { foreach (var a in injuriesDiseases.MRIs) { if (a.File != null) { a.Info = await _imageHandler.UploadImagePath(a.File); } } } if (injuriesDiseases.CommonUltrasounds != null) { foreach (var a in injuriesDiseases.CommonUltrasounds) { if (a.File != null) { a.Info = await _imageHandler.UploadImagePath(a.File); } } } if (injuriesDiseases.Radiographies != null) { foreach (var a in injuriesDiseases.Radiographies) { if (a.File != null) { a.Info = await _imageHandler.UploadImagePath(a.File); } } } }
public async Task <IActionResult> PostWithInjuriesDiseases(int id, [FromForm] InjuriesDiseasesView injuriesDiseasesView) { try { if (id == 0) { return(BadRequest("id is zero")); } if (injuriesDiseasesView == null) { return(BadRequest("Owner object is null")); } if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } await _uploadFileAndSavePath.UloadFile(injuriesDiseasesView); _patientRepository.InsertInjuriesDiseases(id, injuriesDiseasesView.ViewToEntity()); return(Ok()); } catch (Exception ex) { return(StatusCode(500, string.Format("Internal server error. Message error: {0}", ex.Message))); } }
public async Task <IActionResult> Put([FromForm] InjuriesDiseasesView injuriesDiseasesView) { try { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } await _uploadFileAndSavePath.UloadFile(injuriesDiseasesView); if (_injuriesDiseasesRepository.UpdateFull(injuriesDiseasesView.ViewToEntity())) { return(Ok()); } return(NotFound()); } catch { return(BadRequest()); } }
public static InjuriesDiseases ViewToEntity(this InjuriesDiseasesView view) { if (view != null) { return(new InjuriesDiseases { Id = view.Id, DateInjuriesOrDiseases = view.DateInjuriesOrDiseases, ReleasedInMainGroup = view.ReleasedInMainGroup, DisabilityCountDay = (view.ReleasedInMainGroup - view.DateInjuriesOrDiseases).Days, Diagnosis = view.Diagnosis, DrugTherapy = view.DrugTherapy, PhysiotherapyTreatment = view.PhysiotherapyTreatment, Other = view.Other, DisabilityTypeId = (int)view.DisabilityType, PatientId = view.PatientId, MRIs = view.MRIs.ViewToEntity() ?? new List <MRI>(), CommonUltrasounds = view.CommonUltrasounds.ViewToEntity() ?? new List <CommonUltrasound>(), Radiographies = view.Radiographies.ViewToEntity() ?? new List <Radiography>() }); } return(null); }