Exemplo n.º 1
0
        public ActionResult GenerateDoc(PreLiveVM model)
        {
            _facilityQuestionnaireService.SaveChanges(model, loggedInUser.Id, loggedInUser.FullName);

            var path     = Server.MapPath("~/Documents");
            var fileName = Guid.NewGuid() + ".docx";

            path = path + "\\" + fileName;
            model.contactList = _facilityQuestionnaireService.GetContacts(model.FacilityKey);

            model.facilityModel = _facilityService.GetDetails(model.FacilityKey);
            if (model.facilityModel.fac_stt_key.HasValue)
            {
                model.facilityState = _uclService.GetDetails(model.facilityModel.fac_stt_key.Value);
            }

            if (model.facilityModel.fac_ucd_key_system.HasValue)
            {
                model.facilityHealthSystem = _uclService.GetDetails(model.facilityModel.fac_ucd_key_system.Value);
            }

            if (model.facilityModel.fac_ucd_bed_size.HasValue)
            {
                model.bedSizeUCL = _uclService.GetDetails(model.facilityModel.fac_ucd_bed_size.Value);
            }

            model.faclityContract = _facilityContractService.GetDetails(model.FacilityKey);
            var html = RenderPartialViewToString("_PrevLivePreview", model);

            BLL.Helpers.Functions.GenerateDocument(html, path);
            return(Json(new { fileName = fileName }, JsonRequestBehavior.AllowGet));
        }
        public void SaveChanges(PreLiveVM model, string loggedInUserId, string loggedInUserFullName)
        {
            try
            {
                var currentDate = DateTime.Now.ToEST();

                #region Questionnaire Table
                if (!IsQuestionnaireExists(model.FacilityKey))
                {
                    model.questionnaireModel.fqp_created_by      = loggedInUserId;
                    model.questionnaireModel.fqp_created_by_name = loggedInUserFullName;
                    model.questionnaireModel.fqp_created_date    = currentDate;
                    model.questionnaireModel.fqp_key             = model.FacilityKey;
                    _unitOfWork.FacilityQuestionnairePreLiveRepository.Insert(model.questionnaireModel);
                }
                else
                {
                    model.questionnaireModel.fqp_modified_by      = loggedInUserId;
                    model.questionnaireModel.fqp_modified_by_name = loggedInUserFullName;
                    model.questionnaireModel.fqp_modified_date    = currentDate;
                    _unitOfWork.FacilityQuestionnairePreLiveRepository.Update(model.questionnaireModel);
                }
                _unitOfWork.Save();

                #endregion

                #region Contacts Table
                var contacts     = model.contactList?.Where(m => !string.IsNullOrEmpty(m.fqc_name));
                var existingList = _unitOfWork.FacilityQuestionnaireContactRespository.Query()
                                   .Where(m => m.fqc_fqp_key == model.FacilityKey)
                                   .ToList();
                if (existingList.Count() > 0)
                {
                    _unitOfWork.FacilityQuestionnaireContactRespository.DeleteRange(existingList);
                    _unitOfWork.Save();
                }

                var contactsToInsert = contacts.Select(m => new facility_questionnaire_contact
                {
                    fqc_fqp_key         = model.FacilityKey,
                    fqc_fqd_key         = m.fqd_key,
                    fqc_created_by      = loggedInUserId,
                    fqc_created_date    = currentDate,
                    fqc_created_by_name = loggedInUserFullName,
                    fqc_email           = m.fqc_email,
                    fqc_name            = m.fqc_name,
                    fqc_phone           = m.fqc_phone,
                });
                _unitOfWork.FacilityQuestionnaireContactRespository.InsertRange(contactsToInsert);
                _unitOfWork.Save();
                _unitOfWork.Commit();

                #endregion
            }
            catch (Exception ex)
            {
                _unitOfWork.Rollback();
                throw ex;
            }
        }
Exemplo n.º 3
0
        public ActionResult _PreLiveForm(Guid id)
        {
            var obj      = _facilityQuestionnaireService.GetDetails(id);
            var contacts = _facilityQuestionnaireService.GetContacts(id);


            var vm = new PreLiveVM {
                questionnaireModel = obj, contactList = contacts
            };

            vm.FacilityKey = id;
            return(PartialView(vm));
        }
Exemplo n.º 4
0
        public ActionResult Save(PreLiveVM model)
        {
            _facilityQuestionnaireService.SaveChanges(model, loggedInUser.Id, loggedInUser.FullName);

            return(ShowSuccessMessageOnly("Changes successfully updated", model));
        }