public ActionResult Edit(HospitalFacilityEditModel model) { try { if (ModelState.IsValid) { model.OrganizationEditModel.LogoImage = FileObject(model.OrganizationEditModel.Name, "organization_logo", _mediaRepository.GetOrganizationLogoImageFolderLocation(), model.OrganizationEditModel.LogoImage != null ? model.OrganizationEditModel.LogoImage.Id : 0); model.ResultLetterFile = FileObject(model.OrganizationEditModel.Name, "result_letter", _mediaRepository.GetOrganizationResultLetterFolderLocation(), model.ResultLetterFile != null ? model.ResultLetterFile.Id : 0); model.OrganizationEditModel.OrganizationType = OrganizationType.HospitalFacility; _organizationService.CreateHospitalFacility(model); model.FeedbackMessage = FeedbackMessageModel.CreateSuccessMessage(string.Format("The hospital facility {0} was saved successfully.", model.OrganizationEditModel.Name)); return(View(model)); } return(View(model)); } catch (Exception ex) { model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Failure. Message: " + ex.Message); return(View(model)); } }
public long CreateHospitalFacility(HospitalFacilityEditModel model) { long toDeleteFileId = 0; if (model.ResultLetterFile != null) { model.ResultLetterFile = _fileRepository.Save(model.ResultLetterFile); } if (model.OrganizationEditModel.Id > 0) { var inDb = _hospitalFacilityRepository.GetHospitalFacility(model.OrganizationEditModel.Id); if (inDb.ResultLetterFileId.HasValue && inDb.ResultLetterFileId.Value > 0 && (model.ResultLetterFile == null || inDb.ResultLetterFileId != model.ResultLetterFile.Id)) { toDeleteFileId = inDb.ResultLetterFileId.Value; } } var hospitalFacility = Mapper.Map <HospitalFacilityEditModel, HospitalFacility>(model); var organizationId = Create(model.OrganizationEditModel); hospitalFacility.Id = organizationId; _hospitalFacilityRepository.Save(hospitalFacility); if (toDeleteFileId > 0) { ((IFileRepository)_fileRepository).Delete(toDeleteFileId); } return(organizationId); }
// // GET: /Users/HospitalFacility/ public ActionResult Create() { var model = new HospitalFacilityEditModel(); return(View(model)); }