コード例 #1
0
        public ActionResult Edit([Bind(Include = "Id, RefundableProduct, SubNumber, Employee, GuarantorStatus, Notes")] Guarantor guarantor)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    GuarantorServices.Update(CurrentUser.Id, guarantor, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "UpdateConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            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));
        }
コード例 #2
0
        public ActionResult Approve(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("ManageValidRequests"));
            }
            try
            {
                // 1- update loan reuest status
                Request request = RequestServices.Get(id.Value);
                request.RequestStatus = (int)RequestStatusEnum.Approved;
                RequestServices.Update(request);

                // 2- update guarantors status
                List <Guarantor> Guarantors = GuarantorServices.GetByRefundableProduct(id.Value);
                for (int i = 0; i < Guarantors.Count; i++)
                {
                    Guarantor temp = Guarantors[i];
                    temp.GuarantorStatus = (int)GuarantorStatusEnum.UnderStudy;
                    GuarantorServices.Update(temp);
                }
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("ManageValidRequests"));
        }
コード例 #3
0
        public ActionResult EditGuarantorWithStatement(GuarantorWithStatmentViewModel model)
        {
            try
            {
                Db db = new Db(DbServices.ConnectionString);
                if (!(db.Connection.State == ConnectionState.Open))
                {
                    db.Connection.Open();
                }
                db.Transaction = db.Connection.BeginTransaction();

                if (ModelState.IsValid)
                {
                    try
                    {
                        // 1- Update Guaratntor
                        GuarantorServices.Update(CurrentUser.Id, model.Guarantor, db);

                        //2-Update GuarantorStatement
                        model.GuarantorStatement.Guarantor = model.Guarantor.Id;
                        GuarantorStatementServices.Update(CurrentUser.Id, model.GuarantorStatement, db);

                        TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "UpdateConfirmed");
                    }
                    catch (CfException cfex)
                    {
                        TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                    }
                    catch (Exception ex)
                    {
                        TempData["Failure"] = ex.Message;
                    }
                }

                if (db.Transaction != null)
                {
                    db.Transaction.Commit();
                }
                return(RedirectToAction("Details", new { id = model.Guarantor.RefundableProduct }));
            }
            catch
            {
                return(View());
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public ActionResult CreateGuarantorWithStatement(GuarantorWithStatmentViewModel model)
        {
            try
            {
                Db db = new Db(DbServices.ConnectionString);
                if (!(db.Connection.State == ConnectionState.Open))
                {
                    db.Connection.Open();
                }
                db.Transaction = db.Connection.BeginTransaction();

                if (ModelState.IsValid)
                {
                    try
                    {
                        model.Guarantor.GuarantorStatus = (int)GuarantorStatusEnum.New;
                        // 1- Add Guaratntor
                        Guarantor g = GuarantorServices.Insert(CurrentUser.Id, model.Guarantor, db);

                        //2-Add GuarantorStatement
                        model.GuarantorStatement.Guarantor = g.Id;
                        GuarantorStatement gs = GuarantorStatementServices.Insert(CurrentUser.Id, model.GuarantorStatement, db);

                        Request           r  = db.RequestGet(model.Guarantor.RefundableProduct);
                        RefundableProduct rp = db.RefundableProductGet(model.Guarantor.RefundableProduct);

                        //Calculate Solvency
                        GetEmployeeSolvencyFilter filter = new GetEmployeeSolvencyFilter()
                        {
                            EmployeeId  = model.Guarantor.Employee,
                            Amount      = r.Amount,
                            Date        = r.Date,
                            Installment = rp.Installment,
                            GrossSalary = model.GuarantorStatement.GrossSalary,
                            NetSalary   = model.GuarantorStatement.NetSalary
                        };
                        GetEmployeeSolvencyResult solvencyResult = db.GetEmployeeSolvencyFirstOrDefault(filter);

                        // update notes field at Guarantor
                        string result = getResult(solvencyResult);
                        g.Notes = result;
                        GuarantorServices.Update(CurrentUser.Id, g, db);

                        TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    }
                    catch (CfException cfex)
                    {
                        TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                    }
                    catch (Exception ex)
                    {
                        TempData["Failure"] = ex.Message;
                    }
                }

                if (db.Transaction != null)
                {
                    db.Transaction.Commit();
                }
                return(RedirectToAction("Details", new { id = model.Guarantor.RefundableProduct }));
            }
            catch
            {
                return(View("Details"));
            }
        }