Пример #1
0
        /// <summary>
        /// Converts the insurance entity to model
        /// </summary>
        /// <param name="ins"></param>
        /// <returns></returns>
        private InsuranceModel ConvertToInsuranceModel(tblInsuranceAgency ins)
        {
            InsuranceModel model = new InsuranceModel();

            using (var context = new lifeflightapps())
            {
                var contacts = context.tblInsuranceAgencyContacts.Where(x => x.InsuranceID == ins.INSURANCEID).ToList();
                List <InsuranceContactModel> contactModels = new List <InsuranceContactModel>();
                contactModels = ConvertToContactsModel(contacts);
                InsuranceModel insModel = new InsuranceModel()
                {
                    InsuranceId     = ins.INSURANCEID,
                    InsuranceName   = ins.INSAGENCYNAME,
                    Description     = ins.DESCRIPTION,
                    Instructions    = ins.INSTRUCTIONS,
                    InsurancePhone  = ins.INSURANCEPHONE,
                    InsuranceFax    = ins.INSURANCEFAX,
                    PreAuthRequired = ins.PREAUTHREQUIRED.HasValue ? ins.PREAUTHREQUIRED.Value : false,
                    HasOwnPaperWork = ins.HASOWNPAPEROWORK.HasValue ? ins.HASOWNPAPEROWORK.Value : false,
                    CreatedBy       = ins.CREATEDBY,
                    CreatedOn       = ins.CREATEDON,
                    contactModels   = contactModels
                };
                model = insModel;
            }
            return(model);
        }
Пример #2
0
        /// <summary>
        /// Make a DB call to get the insurance details
        /// </summary>
        /// <param name="insAgencyId"></param>
        /// <returns></returns>
        public InsuranceModel GetInsuranceFromDB(int insAgencyId)
        {
            InsuranceModel     model           = new InsuranceModel();
            tblInsuranceAgency insuranceAgency = new tblInsuranceAgency();

            using (var context = new lifeflightapps())
            {
                insuranceAgency = context.tblInsuranceAgencies.Find(insAgencyId);
                model           = ConvertToInsuranceModel(insuranceAgency);
            }
            return(model);
        }
Пример #3
0
        /// <summary>
        /// Add new insurance agency
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Description"></param>
        /// <param name="Phone"></param>
        /// <param name="Fax"></param>
        /// <param name="PreAuth"></param>
        /// <param name="OwnPaper"></param>
        /// <param name="Instructions"></param>
        /// <returns></returns>
        public JsonResult AddNewInsuranceAgency(string Name, string Description, string Phone, string Fax, bool PreAuth, bool OwnPaper, string Instructions)
        {
            int insuranceID = 0;

            using (var context = new lifeflightapps())
            {
                tblInsuranceAgency insAgency = new tblInsuranceAgency()
                {
                    INSAGENCYNAME   = Name,
                    DESCRIPTION     = Description,
                    INSURANCEPHONE  = Phone,
                    INSURANCEFAX    = Fax,
                    PREAUTHREQUIRED = PreAuth,
                    INSTRUCTIONS    = Instructions,
                    CREATEDBY       = User.Identity.Name,
                    CREATEDON       = DateTime.Now
                };
                context.tblInsuranceAgencies.Add(insAgency);
                context.SaveChanges();
                insuranceID = insAgency.INSURANCEID;
            }
            return(Json(insuranceID, JsonRequestBehavior.AllowGet));
        }