Exemplo n.º 1
0
        public ActionResult Edit(int id, PolicyModel model)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);
                    return(View(policyDetailModel));
                }

                model.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName(model.StatusName);

                var entity = AutoMapper.Mapper.Map <Policy>(model);
                Uow.Policies.Update(entity);
                Uow.SaveChanges();

                if (string.IsNullOrEmpty(model.ReturnUrl) == false)
                {
                    return(Redirect(model.ReturnUrl));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);
                return(View(policyDetailModel));
            }
        }
Exemplo n.º 2
0
        // GET: Policy/Create
        public ActionResult Create(int?ClientId, string returnUrl)
        {
            if (ClientId.HasValue == false)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PolicyDetailModel vm = new PolicyDetailModel()
            {
                Companies     = ListProviderSvc.GetInsuranceProviders(),
                PolicyTypes   = ListProviderSvc.GetPolicyTypes(),
                Statuses      = ListProviderSvc.GetPolicyStatuses(),
                Agents        = ListProviderSvc.GetAgents(),
                InceptionDate = DateTime.Now,
                DateIssued    = DateTime.Now,
                ExpiryDate    = DateTime.Now,
                StatusName    = "New",
                ReturnUrl     = returnUrl,
                ClientId      = (int)ClientId
            };

            List <ClientSimple> clients = null;

            if (ClientId == 0)
            {
                clients = ListProviderSvc.GetClientSimpleList();
            }
            else
            {
                clients = new List <ClientSimple>();
                var clientEntity = Uow.Clients.GetById((int)ClientId);
                if (clientEntity == null)
                {
                    return(HttpNotFound());
                }
                ClientSimple client = new ClientSimple
                {
                    Id = clientEntity.Id,
                };
                if (clientEntity.IsOrganization)
                {
                    client.ClientName = clientEntity.OrganizationName;
                }
                else
                {
                    client.ClientName = clientEntity.LastName + ", " + clientEntity.FirstName;
                }

                clients.Add(client);
            }
            vm.Clients = clients;

            List <DefaultRebate> defaultRebates = null;

            defaultRebates    = ListProviderSvc.GetDefaultRebates();
            vm.DefaultRebates = defaultRebates;

            return(View(vm));
        }
Exemplo n.º 3
0
 // GET: PolicyDetails
 public ActionResult Index()
 {
     if (TempData["policyData"] == null)
     {
         ViewBag.ShowList = false;
         return(View());
     }
     else
     {
         PolicyDetailModel lst = (PolicyDetailModel)TempData["policyData"];
         ViewBag.ShowList = true;
         return(View(lst));
     }
 }
Exemplo n.º 4
0
        // GET: Policy/Edit/5
        public ActionResult Edit(int?id, string returnUrl)
        {
            if (id.HasValue == false)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);

            policyDetailModel.ReturnUrl = returnUrl;

            if (policyDetailModel.StatusName.ToLower() != "active")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            return(View(policyDetailModel));
        }
Exemplo n.º 5
0
        public ActionResult CreateAttachment(PolicyDetailModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                model.NewAttachment.PolicyId = model.Id;
                SaveFile(model.NewAttachment, fileUpload);

                PolicyAttachment entity = AutoMapper.Mapper.Map <PolicyAttachment>(model.NewAttachment);
                entity.PolicyId   = model.Id;
                entity.PostedDate = DateTime.Now;
                Uow.PolicyAttachments.Add(entity);
                Uow.SaveChanges();

                return(RedirectToAction("Details", "Policy", new { id = model.Id }));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(RedirectToAction("Details", "Policy", new { id = model.Id }));
            }
        }
Exemplo n.º 6
0
        public ActionResult CreateEndorsement(PolicyDetailModel policyDetailModel)
        {
            try
            {
                var model = policyDetailModel.Endt;
                if (model.IsRet)
                {
                    model.EndorsementAmount *= -1;
                }
                var entity = AutoMapper.Mapper.Map <Endorsement>(model);
                Uow.Endorsements.Add(entity);

                UpdatePolicyAndInvoices(model);
                Uow.SaveChanges();

                return(RedirectToAction("Details", new { id = model.PolicyId }));
            }
            catch (Exception ex)
            {
                var model = policyDetailModel.Endt;
                return(RedirectToAction("Details", new { id = model.PolicyId }));
            }
        }
        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));
        }