Example #1
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));
        }