/// <summary>
        /// Returns a list of ExceptionalAmountVw objects
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(ExceptionalAmountVwViewModel Model)
        {
            Db db = new Db(DbServices.ConnectionString);

            Model.List = ExceptionalAmountVwServices.List(db);
            return(View(Model));
        }
 private void FormExceptionalAmountView_Load(object sender, EventArgs e)
 {
     if (dataSource == null)
     {
         DateTime dt = DateTime.Now;
         DataSource = ExceptionalAmountVwServices.List(new Db(DbServices.ConnectionString));
         slblEllapsedTimeValue.Text = (DateTime.Now.Subtract(dt).TotalMilliseconds / 1000).ToString();
     }
 }
        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));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExceptionalAmountVwViewModel exceptionalAmountVwViewModel = new ExceptionalAmountVwViewModel();

            Db db = new Db(DbServices.ConnectionString);

            // exceptionalAmountVwViewModel.Instance = ExceptionalAmountVwServices.Get(id.Value, db);
            exceptionalAmountVwViewModel.Instance = ExceptionalAmountVwServices.GetChildren(id.Value, db);
            if (exceptionalAmountVwViewModel.Instance == null)
            {
                return(HttpNotFound());
            }


            return(View(exceptionalAmountVwViewModel));
        }
        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));
        }