示例#1
0
        // GET: Insurer
        public ActionResult Index()
        {
            var service = new InsurerService();
            var model   = service.GetInsurers();

            ViewBag.TotalCount = model.ToList().Count();
            return(View(model));
        }
        public PolicyDetail ProductDetail()
        {
            var model      = new PolicyDetailModel();
            var InsService = new InsurerService();

            model.CurrencyId       = InsuranceContext.Currencies.All().FirstOrDefault().Id;
            model.PolicyStatusId   = InsuranceContext.PolicyStatuses.All().FirstOrDefault().Id;
            model.BusinessSourceId = InsuranceContext.BusinessSources.All().FirstOrDefault().Id;
            //model.Products = InsuranceContext.Products.All().ToList();
            model.InsurerId = InsService.GetInsurers().FirstOrDefault().Id;
            var objList = InsuranceContext.PolicyDetails.All(orderBy: "Id desc").FirstOrDefault();

            if (objList != null)
            {
                string number       = objList.PolicyNumber.Split('-')[0].Substring(4, objList.PolicyNumber.Length - 6);
                long   pNumber      = Convert.ToInt64(number.Substring(2, number.Length - 2)) + 1;
                string policyNumber = string.Empty;
                int    length       = 7;
                length = length - pNumber.ToString().Length;
                for (int i = 0; i < length; i++)
                {
                    policyNumber += "0";
                }
                policyNumber        += pNumber;
                ViewBag.PolicyNumber = "GMCC" + DateTime.Now.Year.ToString().Substring(2, 2) + policyNumber + "-1";
                model.PolicyNumber   = ViewBag.PolicyNumber;
            }
            else
            {
                ViewBag.PolicyNumber = ConfigurationManager.AppSettings["PolicyNumber"] + "-1";
                model.PolicyNumber   = ViewBag.PolicyNumber;
            }

            model.BusinessSourceId = 3;

            return(Mapper.Map <PolicyDetailModel, PolicyDetail>(model));
        }