// 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));
        }
        private PolicyDetailModel GetPolicyDetailModel(int?id)
        {
            var policyDetailModel = Uow.Policies.GetAll()
                                    .Where(c => c.Id == id)
                                    .ProjectTo <PolicyDetailModel>()
                                    .FirstOrDefault();

            if (policyDetailModel.IsOrganization)
            {
                policyDetailModel.ClientName = policyDetailModel.OrganizationName;
            }

            policyDetailModel.Companies   = ListProviderSvc.GetInsuranceProviders();
            policyDetailModel.PolicyTypes = ListProviderSvc.GetPolicyTypes();
            policyDetailModel.Statuses    = ListProviderSvc.GetPolicyStatuses();
            policyDetailModel.Agents      = ListProviderSvc.GetAgents();
            policyDetailModel.Clients     = ListProviderSvc.GetClientSimpleList();

            return(policyDetailModel);
        }