public ActionResult BillDetail(int id)
        {
            CustomerBillingInfoDAORequest request = new CustomerBillingInfoDAORequest();
            CustomerbillinginfoViewModel  model   = request.GetBillById(id);

            return(RedirectToAction("CustomerPolicyBillView", model));
        }
        public ActionResult EditCustomerBill(int id)
        {
            CustomerbillinginfoViewModel c = csb.GetEdit(id);

            ViewData["csbAllView"] = c;
            List <CustomerpolicyViewModel> z = csp.GetAll();

            Session["cspAllView"] = z;
            return(View());
        }
        public ActionResult NewCustomerBill(CustomerbillinginfoViewModel xx)
        {
            csb.Update(xx);
            List <CustomerbillinginfoViewModel> s = csb.GetAll();

            Session["csbAllView"] = s;
            if (Session["CusbillSearch"] == null)
            {
                return(RedirectToAction("CustomerbillViewAll"));
            }

            return(RedirectToAction("customerSearch"));
        }
        public ActionResult CheckBillExist(CustomerbillinginfoViewModel cb)
        {
            CustomerBillingInfoDAORequest       dao   = new CustomerBillingInfoDAORequest();
            List <CustomerbillinginfoViewModel> model = dao.CheckCustomerPolicyExist(cb.id);

            if (model.Count > 0)
            {
                TempData["message"] = "Customer Policy already had a bill, please check Customer Billing Info";
                return(RedirectToAction("CusTomerBillManagerl", new { page = 1, pageSize = 10 }));
            }
            else
            {
                return(RedirectToAction("AddCustomerBill", new { l = cb }));
            }
        }
        public ActionResult AddCustomerBill(CustomerbillinginfoViewModel l)
        {
            List <CustomerbillinginfoViewModel> model = csb.CheckCustomerPolicyExist(l.customerpolicyid);

            if (model.Count > 0)
            {
                TempData["message"] = "Customer Policy already had a bill, please check Customer Billing Info";
                return(RedirectToAction("CusTomerBillManagerl", new { page = 1, pageSize = 10 }));
            }
            else
            {
                csb.Add(l);
                List <CustomerbillinginfoViewModel> x = csb.GetAll();
                Session["csbAllView"] = x;
                return(RedirectToAction("CustomerbillViewAll"));
            }
        }
        public ActionResult CustomerPolicyBillView(CustomerbillinginfoViewModel model)
        {
            var context = new InsuranceDbContext();
            var item    = context.Customer_Billing_Info
                          .Where(c => c.customer_policy_id == model.customerpolicyid)
                          .Select(c => new CustomerPolicyBillViewModel
            {
                Amount           = c.amount,
                BillNumber       = c.bill_number,
                CreateDate       = c.create_date,
                CustomerName     = c.Customer_Policy.Customer_Info.name,
                CustomerPolicyId = (int)c.customer_policy_id,
                EndDate          = c.Customer_Policy.policy_end_date,
                PolicyName       = c.Customer_Policy.Policy.policy_number,
                StartDate        = c.Customer_Policy.policy_start_date,
                VehicleName      = c.Customer_Policy.Vehicle_Info.Brand.name + " " + c.Customer_Policy.Vehicle_Info.Model.name
            }).FirstOrDefault();

            return(View(item));
        }
        public ActionResult CreateBillForCustomer()
        {
            int      customerPolicyId = int.Parse(Request.Params["customerPolicyId"]);
            string   customerProve    = Request.Params["customeraddprove"];
            string   billNumber       = Request.Params["bill_number"];
            DateTime createDate       = DateTime.Parse(Request.Params["createDate"]);
            decimal  amount           = decimal.Parse(Request.Params["amount"]);
            bool     active           = Request.Params["active"] == "TRUE" ? true : false;

            CustomerbillinginfoViewModel model = new CustomerbillinginfoViewModel()
            {
                customerpolicyid = customerPolicyId,
                active           = active,
                amount           = amount,
                bill_number      = billNumber,
                createdate       = createDate,
                customeraddprove = customerProve
            };

            CustomerBillingInfoDAORequest request = new CustomerBillingInfoDAORequest();

            request.Add(model);
            return(RedirectToAction("CustomerPolicyBillView", model));
        }