// GET: Guarantor/Delete/5
        public ActionResult DeleteGuarantorWithStatement(Nullable <int> id, int ProductId)
        {
            //ViewBag.ModuleName = moduleName;
            ViewBag.Title         = delete;
            ViewBag.Delete        = delete;
            ViewBag.Yes           = yes;
            ViewBag.No            = no;
            ViewBag.ConfirmDelete = confirmDelete;
            ViewBag.Action        = delete;

            ViewBag.TitleGuarantor = TitleGuarantor;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db        db        = new Db(DbServices.ConnectionString);
            Guarantor guarantor = GuarantorServices.Get(id.Value, db);

            if (guarantor == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductId = ProductId;
            return(PartialView(guarantor));
        }
        // GET: Guarantor/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db        db        = new Db(DbServices.ConnectionString);
            Guarantor guarantor = GuarantorServices.Get(id.Value, db);

            if (guarantor == null)
            {
                return(HttpNotFound());
            }
            return(View(guarantor));
        }
        // GET: Guarantor/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Guarantor guarantor = GuarantorServices.Get(id.Value, db);

            if (guarantor == null)
            {
                return(HttpNotFound());
            }

            ViewBag.EmployeeList          = new SelectList(EmployeeServices.List(db), "Id", "FirstName", guarantor.Employee);
            ViewBag.GuarantorStatusList   = new SelectList(GuarantorStatusServices.List(db), "Id", "Name", guarantor.GuarantorStatus);
            ViewBag.RefundableProductList = new SelectList(RefundableProductServices.List(db), "Product", "Name", guarantor.RefundableProduct);
            return(View(guarantor));
        }
        public string RejectGuarantor(int?id)
        {
            string StartDivReject = "<div class='alert alert-danger no-border mb-2' role='alert'><strong>";
            string EndDiv         = "</strong></div> ";

            try
            {
                if (id == null)
                {
                    return("Error");
                }
                Guarantor g = GuarantorServices.Get(id.Value);
                g.GuarantorStatus = (int)GuarantorStatusEnum.Rejected;
                GuarantorServices.Update(g);
            }
            catch (Exception ex)
            {
                return("Error");
            }
            return(StartDivReject + "Rejected" + EndDiv);
        }
        public ActionResult EditGuarantorWithStatement(int?id)
        {
            ViewBag.ModuleName = moduleName;
            ViewBag.Action     = update;
            ViewBag.Update     = update;
            ViewBag.Save       = save;
            ViewBag.Back       = back;
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Guarantor guarantor = GuarantorServices.Get(id.Value, db);

            if (guarantor == null)
            {
                return(HttpNotFound());
            }


            GuarantorStatement guarantorStatement = GuarantorStatementServices.Get(guarantor.Id, db);

            if (guarantorStatement == null)
            {
                return(HttpNotFound());
            }


            ViewBag.EmployeeList        = new SelectList(EmployeeServices.List(db), "Id", "Id_Name", guarantor.Employee);
            ViewBag.GuarantorStatusList = new SelectList(GuarantorStatusServices.List(db), "Id", "Name", guarantor.GuarantorStatus);
            ViewBag.ProductId           = guarantor.RefundableProduct;
            GuarantorWithStatmentViewModel vm = new GuarantorWithStatmentViewModel();

            vm.Guarantor          = guarantor;
            vm.GuarantorStatement = guarantorStatement;


            return(PartialView(vm));
        }