コード例 #1
0
        public string Validate(decimal?Amount, int?RequestId)
        {
            if (RequestId == 0)
            {
                return("Error");// RedirectToAction("ManageNewRequests");
            }
            try
            {
                Db db = new Db(DbServices.ConnectionString);

                LoanRequestVw       request    = LoanRequestVwServices.Get(RequestId.Value);
                RefundableProductVw refendable = RefundableProductVwServices.Get(RequestId.Value);
                int numOfGuarantorsNeeded      = 0;

                EmployeeProductCalculatorFilter f = new EmployeeProductCalculatorFilter();
                f.EmployeeId = request.RequestProductEmployeeId; f.ProductTypeId = (short)request.RequestProductProductTypeId;
                f.Amount     = (decimal)request.RequestAmount; f.Period = (short)refendable.PaymentPeriod;
                List <EmployeeProductCalculatorResult> result = db.EmployeeProductCalculator(f);
                if (result.Count > 0)
                {
                    numOfGuarantorsNeeded = result[0].GuarantorsCount.Value;
                }

                int numOfGuarantors = GuarantorVwServices.GetByRefundableProductProductId(RequestId.Value).Count;
                if (numOfGuarantors == numOfGuarantorsNeeded)
                {
                    Product p = ProductServices.Get(RequestId.Value, db);
                    p.Amount = Amount.Value;
                    ProductServices.Update(p);
                    Request r = RequestServices.Get(RequestId.Value);
                    r.RequestStatus = (int)RequestStatusEnum.Valid;
                    RequestServices.Update(r);
                }
                else
                {
                    //TempData["Failure"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "Guarantors", "NumberOfGuarantors");
                    return(ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "Guarantors", "NumberOfGuarantors"));
                }
            }
            catch (Exception e)
            {
                //EventLog eventLog = DbServices.Log(CurrentUser.Id, db, (int)EventCategoryEnum.Department, (int)EventSourceEnum.Department, (int)EventStatusEnum.Insert, new DepartmentVwXmlFormatter(instance), handler);
                //if (eventLog != null)
                //    throw DbServices.LogError(eventLog, ex, "Department", db);
                //else
                //    throw ex;
            }
            return("Success");// RedirectToAction("ManageNewRequests");
        }
コード例 #2
0
        public ActionResult Index(LoanRequestVwViewModel Model)
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.ProductTypeList   = new SelectList(LoanTypeVwServices.List(db), "ProductTypeId", "ProductTypeName");
            ViewBag.RequestStatusList = new SelectList(RequestStatusServices.List(db), "Id", "Name");

            if (Model.Filter.HasCriteria)
            {
                Model.List = LoanRequestVwServices.Get(Model.Filter, db);
            }
            else
            {
                Model.List = new List <LoanRequestVw>();
            }
            return(View(Model));
        }
コード例 #3
0
        public ActionResult Details(int?id)
        {
            ViewBag.TitleGuarantor        = TitleGuarantor;
            ViewBag.TitleExceptionalAount = TitleExceptionalAount;

            // Details Of Products

            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(RedirectToAction("Index"));
            }

            Db db = new Db(DbServices.ConnectionString);

            ProductVwViewModel productVwViewModel = new ProductVwViewModel();

            productVwViewModel.Instance = ProductVwServices.GetChildren(id.Value, db);
            if (productVwViewModel.Instance == null)
            {
                return(HttpNotFound());
            }
            productVwViewModel.RequestVwViewModel.Instance = RequestVwServices.Get(id.Value);
            productVwViewModel.RequestVwViewModel.LoanRequestVwViewModel.Instance = LoanRequestVwServices.Get(id.Value);
            productVwViewModel.RefundableProductVwViewModel.Instance = RefundableProductVwServices.Get(id.Value);

            List <GuarantorVw> Guarantors = GuarantorVwServices.GetByRefundableProductProductId(id.Value);

            productVwViewModel.RefundableProductVwViewModel.GuarantorVwViewModel.List = Guarantors;

            //productVwViewModel.RefundableProductVwViewModel.GuarantorVwViewModel.Instance.GuarantorStatementVw=GuarantorStatementVwServices.

            productVwViewModel.RequestVwViewModel.LoanRequestVwViewModel.ExceptionalAmountVwViewModel.List = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value);

            List <ExceptionalAmountVw> NetDeduction         = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value).Where(c => c.ExceptionalAmountTypeId == (int)ExceptionalAmountTypeEnum.NetDeduction).ToList();
            List <ExceptionalAmountVw> ExceptionalIncome    = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value).Where(c => c.ExceptionalAmountTypeId == (int)ExceptionalAmountTypeEnum.ExceptionalIncome).ToList();
            List <ExceptionalAmountVw> ExceptionalDeduction = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value).Where(c => c.ExceptionalAmountTypeId == (int)ExceptionalAmountTypeEnum.ExceptionalDeduction).ToList();

            ViewBag.NetDeduction         = NetDeduction;
            ViewBag.ExceptionalIncome    = ExceptionalIncome;
            ViewBag.ExceptionalDeduction = ExceptionalDeduction;

            return(PartialView(productVwViewModel));
        }
コード例 #4
0
        public ActionResult Details(int?id)
        {
            ViewBag.TitleGuarantor        = TitleGuarantor;
            ViewBag.TitleExceptionalAount = TitleExceptionalAount;
            ViewBag.ExceptionalIncome     = exceptionalIncome;
            ViewBag.ExceptionalDeduction  = exceptionalDeduction;
            ViewBag.NetDeduction          = netDeduction;

            // Details Of Products
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            Db db = new Db(DbServices.ConnectionString);

            // Product
            ProductVwViewModel productVwViewModel = new ProductVwViewModel();

            productVwViewModel.Instance = ProductVwServices.GetChildren(id.Value, db);
            if (productVwViewModel.Instance == null)
            {
                return(HttpNotFound());
            }

            productVwViewModel.RequestVwViewModel.Instance = RequestVwServices.Get(id.Value);
            productVwViewModel.RequestVwViewModel.LoanRequestVwViewModel.Instance = LoanRequestVwServices.Get(id.Value);
            productVwViewModel.RefundableProductVwViewModel.Instance = RefundableProductVwServices.Get(id.Value);

            List <GuarantorVw> Guarantors = GuarantorVwServices.GetByRefundableProductProductId(id.Value);

            productVwViewModel.RefundableProductVwViewModel.GuarantorVwViewModel.List = Guarantors;


            productVwViewModel.RequestVwViewModel.LoanRequestVwViewModel.ExceptionalAmountVwViewModel.List = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value);

            List <ExceptionalAmountVw> NetDeduction         = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value).Where(c => c.ExceptionalAmountTypeId == (int)ExceptionalAmountTypeEnum.NetDeduction).ToList();
            List <ExceptionalAmountVw> ExceptionalIncome    = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value).Where(c => c.ExceptionalAmountTypeId == (int)ExceptionalAmountTypeEnum.ExceptionalIncome).ToList();
            List <ExceptionalAmountVw> ExceptionalDeduction = ExceptionalAmountVwServices.GetByLoanRequestRequestProductId(id.Value).Where(c => c.ExceptionalAmountTypeId == (int)ExceptionalAmountTypeEnum.ExceptionalDeduction).ToList();

            ViewBag.NetDeductionList         = NetDeduction;
            ViewBag.ExceptionalIncomeList    = ExceptionalIncome;
            ViewBag.ExceptionalDeductionList = ExceptionalDeduction;

            // Calculate Solvency and Boundries

            EmployeeProductCalculatorFilter f = new EmployeeProductCalculatorFilter()
            {
                EmployeeId    = productVwViewModel.Instance.EmployeeId,
                ProductTypeId = productVwViewModel.Instance.ProductTypeId,
                Amount        = productVwViewModel.RequestVwViewModel.Instance.Amount,
                Period        = productVwViewModel.RefundableProductVwViewModel.Instance.PaymentPeriod
            };

            EmployeeProductCalculatorResult result = db.EmployeeProductCalculatorFirstOrDefault(f);

            if (result != null)
            {
                GetEmployeeSolvencyFilter filter = new GetEmployeeSolvencyFilter()
                {
                    EmployeeId  = productVwViewModel.Instance.EmployeeId,
                    Amount      = productVwViewModel.RequestVwViewModel.Instance.Amount,
                    Date        = System.DateTime.Now,
                    Installment = result.Installment,
                    GrossSalary = productVwViewModel.RequestVwViewModel.LoanRequestVwViewModel.Instance.NetIncome,
                    NetSalary   = productVwViewModel.RequestVwViewModel.LoanRequestVwViewModel.Instance.NetIncome
                };
                GetEmployeeSolvencyResult solvencyResult = db.GetEmployeeSolvencyFirstOrDefault(filter);
                ViewBag.Calculator = result;
                ViewBag.Solvency   = solvencyResult;
            }


            return(View(productVwViewModel));
        }