Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Product, LoanDecision, LoanType, LoanGenerationStatus, LoanStatus")] Loan loan)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    LoanServices.Update(CurrentUser.Id, loan, 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.LoanDecisionList         = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber", loan.LoanDecision);
            ViewBag.LoanGenerationStatusList = new SelectList(LoanGenerationStatusServices.List(db), "Id", "Name", loan.LoanGenerationStatus);
            ViewBag.LoanStatusList           = new SelectList(LoanStatusServices.List(db), "Id", "Name", loan.LoanStatus);
            ViewBag.LoanTypeList             = new SelectList(LoanTypeServices.List(db), "ProductType", "Name", loan.LoanType);
            ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes", loan.Product);
            return(View(loan));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id, Number, Year, Date, DeductionStartDate, CersNumber, CersDate, Notes, LoanDecisionType, PaymentNumber, PaymentDate, IsPaidFromSalary, Reason, AdditionalClause, AdditionalIntroduction")] LoanDecision loanDecision)
        {
            Db db = new Db(DbServices.ConnectionString);

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

            ViewBag.LoanDecisionTypeList = new SelectList(LoanDecisionTypeServices.List(db), "Id", "Name");
            return(View(loanDecision));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Loan, LoanDecision, MainWorkPlace, ApprovedAmount, NetAmount, ProfitAmount")] OutgoingLoan outgoingLoan)
        {
            Db db = new Db(DbServices.ConnectionString);

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

            ViewBag.LoanList          = new SelectList(LoanServices.List(db), "Product", "Name");
            ViewBag.LoanDecisionList  = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber");
            ViewBag.MainWorkPlaceList = new SelectList(MainWorkPlaceServices.List(db), "Id", "Name");
            return(View(outgoingLoan));
        }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.LoanList          = new SelectList(LoanServices.List(db), "Product", "Name");
            ViewBag.LoanDecisionList  = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber");
            ViewBag.MainWorkPlaceList = new SelectList(MainWorkPlaceServices.List(db), "Id", "Name");
            return(View());
        }
        public Response ProcessMoveLoanToEmployee(List <SelectedLoans> loans, int oldEmployeeId, int newEmployeeId)
        {
            Db       db       = new Db();
            Response response = new Cf.ViewModels.Response();

            try
            {
                if (!(db.Connection.State == ConnectionState.Open))
                {
                    db.Connection.Open();
                }
                db.Transaction = db.Connection.BeginTransaction();

                // 1- Loan Decision
                LoanDecision loanDecision = new LoanDecision()
                {
                    Date = System.DateTime.Now,
                    Year = (short)System.DateTime.Now.Year,
                    DeductionStartDate = System.DateTime.Now,
                    LoanDecisionType   = (int)LoanDecisionTypeEnum.ChangeSubscriber
                };
                loanDecision = LoanDecisionServices.Insert(loanDecision);

                // 2- move loans
                foreach (SelectedLoans loan in loans)
                {
                    if (loan.IsSelected)
                    {
                        List <EmployeeProductCalculatorResult> result = db.EmployeeProductCalculator(newEmployeeId, (short)loan.ProductTypeId, loan.RemainingAmount, (short)loan.RemainingPeriod);
                        if (result.Count > 0)
                        {
                            db.LoanMoveFromEmployeeToEmployee(loan.LoanId, newEmployeeId, loanDecision.Id);
                        }
                    }
                }
                db.Transaction.Commit();
                db.Connection.Close();
                response.IsSuccess = true;
            }
            catch (CfException exc)
            {
                db.Transaction.Rollback();
                db.Connection.Close();
                response.IsSuccess = false;
                response.Messages.Add(exc.ErrorDefinition.LocalizedMessage);
            }
            catch (Exception exc)
            {
                db.Transaction.Rollback();
                db.Connection.Close();
                response.IsSuccess = false;
                response.Messages.Add(exc.Message);
            }
            return(response);
        }
Exemplo n.º 6
0
        public ActionResult CreateLoanRequestDecision(ManageLoanDecision model)
        {
            try
            {
                Db db = new Db(DbServices.ConnectionString);

                if (ModelState.IsValid)
                {
                    try
                    {
                        int numberOfCheckedRequests = model.Requests.Where(c => c.isChecked).Count();

                        if (numberOfCheckedRequests != 0)
                        {
                            // 1- Add Loan Decision
                            model.LoanDecision.LoanDecisionType = (int)LoanDecisionTypeEnum.Normal;
                            if (model.LoanDecision.IsPaidFromSalary == null)
                            {
                                model.LoanDecision.IsPaidFromSalary = false;
                            }
                            LoanDecision instance = LoanDecisionServices.Insert(CurrentUser.Id, model.LoanDecision, db);

                            // 2- Add Loans
                            for (int i = 0; i < model.Requests.Count; i++)
                            {
                                if (!model.Requests[i].isChecked)
                                {
                                    continue;
                                }
                                db.LoanGenerate(model.Requests[i].RequestId, instance.Id, (int)LoanGenerationStatusEnum.LoanRequest);
                            }
                            TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (CfException cfex)
                    {
                        TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                    }
                    catch (Exception ex)
                    {
                        TempData["Failure"] = ex.Message;
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 7
0
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.LoanDecisionList         = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber");
            ViewBag.LoanGenerationStatusList = new SelectList(LoanGenerationStatusServices.List(db), "Id", "Name");
            ViewBag.LoanStatusList           = new SelectList(LoanStatusServices.List(db), "Id", "Name");
            ViewBag.LoanTypeList             = new SelectList(LoanTypeServices.List(db), "ProductType", "Name");
            ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes");
            return(View());
        }
Exemplo n.º 8
0
        ///<summary>
        /// Move Loan To Employee Method
        ///</summary>
        public void MoveLoanToEmployee(int userId, int LoanId, int EmployeeId, LoanDecision loanDecision)
        {
            try
            {
                Db db = new Db(DbServices.ConnectionString);

                // 0- Create Loan Decision
                LoanDecision decision = LoanDecisionServices.Insert(userId, loanDecision, db);

                // 1- Change the Status Of Old Loan to be Move To Employee
                Loan loan = LoanServices.Get(LoanId, db);
                loan.LoanStatus = (int)LoanStatusEnum.MoveToEmployee;
                LoanServices.Update(userId, loan, db);
                // 2- Process the Installments



                // 3- Create New Product + Refundable Product

                LoanRequest req = new LoanRequest()
                {
                    //Request=
                };
                Loan NewLoan = new Loan()
                {
                    LoanDecision         = decision.Id,
                    Product              = loan.Product,
                    LoanGenerationStatus = (int)LoanGenerationStatusEnum.IncommingFromOtherSubscriber,
                    LoanStatus           = (int)LoanStatusEnum.Unfinished,
                    LoanType             = loan.LoanType
                };

                LoanServices.Insert(userId, NewLoan);


                // 2- Add Loan and Generate Installment


                //db.LoanGenerate(model.Requests[i].RequestId, decision.Id, (int)LoanGenerationStatusEnum.LoanRequest);


                // 4- Generate Installment for the new Loan

                //
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 9
0
        // GET: LoanDecision/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db           db           = new Db(DbServices.ConnectionString);
            LoanDecision loanDecision = LoanDecisionServices.Get(id.Value, db);

            if (loanDecision == null)
            {
                return(HttpNotFound());
            }
            return(View(loanDecision));
        }
Exemplo n.º 10
0
        // GET: LoanDecision/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LoanDecision loanDecision = LoanDecisionServices.Get(id.Value, db);

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

            ViewBag.LoanDecisionTypeList = new SelectList(LoanDecisionTypeServices.List(db), "Id", "Name", loanDecision.LoanDecisionType);
            return(View(loanDecision));
        }
Exemplo n.º 11
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         Db db = new Db(DbServices.ConnectionString);
         LoanDecisionServices.Delete(CurrentUser.Id, id, db);
         TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "DeleteConfirmed");
         // return RedirectToAction("Index");
     }
     catch (CfException cfex)
     {
         TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
     }
     catch (Exception ex)
     {
         TempData["Failure"] = ex.Message;
     }
     // return View(loanDecision);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 12
0
        // GET: OutgoingLoan/Edit/5
        public ActionResult Edit(Nullable <int> loan)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (loan == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OutgoingLoan outgoingLoan = OutgoingLoanServices.Get(loan.Value, db);

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

            ViewBag.LoanList          = new SelectList(LoanServices.List(db), "Product", "Name", outgoingLoan.Loan);
            ViewBag.LoanDecisionList  = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber", outgoingLoan.LoanDecision);
            ViewBag.MainWorkPlaceList = new SelectList(MainWorkPlaceServices.List(db), "Id", "Name", outgoingLoan.MainWorkPlace);
            return(View(outgoingLoan));
        }
Exemplo n.º 13
0
        // GET: Loan/Edit/5
        public ActionResult Edit(Nullable <int> product)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (product == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Loan loan = LoanServices.Get(product.Value, db);

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

            ViewBag.LoanDecisionList         = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber", loan.LoanDecision);
            ViewBag.LoanGenerationStatusList = new SelectList(LoanGenerationStatusServices.List(db), "Id", "Name", loan.LoanGenerationStatus);
            ViewBag.LoanStatusList           = new SelectList(LoanStatusServices.List(db), "Id", "Name", loan.LoanStatus);
            ViewBag.LoanTypeList             = new SelectList(LoanTypeServices.List(db), "ProductType", "Name", loan.LoanType);
            ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes", loan.Product);
            return(View(loan));
        }
        public Response ProcessMoveLoanToGuarantors(List <SelectedGuarantor> guarantors, int LoanId)
        {
            Db       db       = new Db();
            Response response = new Cf.ViewModels.Response();

            try
            {
                int numberOfGuarantors = guarantors.Where(c => c.IsSelected).ToList().Count;
                if (numberOfGuarantors == 0)
                {
                    db.Transaction.Rollback();
                    db.Connection.Close();
                    response.IsSuccess = false;
                    string message = "No Guarantors was selected";
                    response.Messages.Add(message);
                    TempData["Failure"] = message;
                    return(response);
                }

                if (!(db.Connection.State == ConnectionState.Open))
                {
                    db.Connection.Open();
                }
                db.Transaction = db.Connection.BeginTransaction();

                // 1- Loan Decision
                LoanDecision loanDecision = new LoanDecision()
                {
                    Date = System.DateTime.Now,
                    Year = (short)System.DateTime.Now.Year,
                    DeductionStartDate = System.DateTime.Now,
                    LoanDecisionType   = (int)LoanDecisionTypeEnum.ChangeToGuarantor
                };
                LoanDecision oldDecision = LoanDecisionServices.GetByNumber_YearFirstOrNull(loanDecision.Number, loanDecision.Year);
                if (oldDecision != null)
                {
                    loanDecision.Number = (short)(loanDecision.Number + 1);
                }
                loanDecision = LoanDecisionServices.Insert(loanDecision);

                // 2- move loan to selected guarantors
                foreach (SelectedGuarantor guarantor in guarantors)
                {
                    if (guarantor.IsSelected)
                    {
                        db.LoanMoveFromEmployeeToGuarantor(LoanId, guarantor.GuarantorId, loanDecision.Id, numberOfGuarantors);
                    }
                }
                db.Transaction.Commit();
                db.Connection.Close();
                response.IsSuccess = true;
            }
            catch (CfException exc)
            {
                db.Transaction.Rollback();
                db.Connection.Close();
                response.IsSuccess = false;
                response.Messages.Add(exc.ErrorDefinition.LocalizedMessage);
            }
            catch (Exception exc)
            {
                db.Transaction.Rollback();
                db.Connection.Close();
                response.IsSuccess = false;
                response.Messages.Add(exc.Message);
            }
            return(response);
        }