コード例 #1
0
        public ActionResult Edit(int?id)
        {
            LoanRequestViewModel vm = new LoanRequestViewModel();

            try
            {
                Db db = new Db(DbServices.ConnectionString);

                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Product           product           = ProductServices.Get(id.Value, db);
                Request           request           = RequestServices.Get(id.Value, db);
                LoanRequest       loanRequest       = LoanRequestServices.Get(id.Value, db);
                RefundableProduct refundableProduct = RefundableProductServices.Get(id.Value, db);

                if (product == null || request == null || loanRequest == null || refundableProduct == null)
                {
                    return(HttpNotFound());
                }

                // For Product
                //ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "Id_Name", product.Employee);
                ViewBag.ProductTypeList = new SelectList(ProductTypeServices.List(db), "Id", "Name", product.ProductType);

                // For Request
                //We need to customise the droplist for two options
                ViewBag.BypassStatusList = new SelectList(BypassStatusServices.List(db).Where((c => (c.Id == 0 || c.Id == 2))), "Id", "Name");


                EmployeeProductCalculatorFilter f = new EmployeeProductCalculatorFilter();
                f.EmployeeId = product.Employee; f.ProductTypeId = (short)product.ProductType;
                f.Amount     = (decimal)request.Amount; f.Period = (short)refundableProduct.PaymentPeriod;
                EmployeeProductCalculatorResult result = db.EmployeeProductCalculatorFirstOrDefault(f);
                if (result != null)
                {
                    ViewBag.Calculations = result;
                }

                vm.RequestProduct = product;
                vm.Request        = request;
                vm.LoanRequest    = loanRequest;
                vm.RequestProductProductRefundableProduct = refundableProduct;
            }
            catch (CfException cfex)
            {
                TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
            }
            catch (Exception ex)
            {
                TempData["Failure"] = ex.Message;
            }
            return(View(vm));
        }
コード例 #2
0
        // GET: LoanRequest/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db          db          = new Db(DbServices.ConnectionString);
            LoanRequest loanRequest = LoanRequestServices.Get(id.Value, db);

            if (loanRequest == null)
            {
                return(HttpNotFound());
            }
            return(View(loanRequest));
        }
コード例 #3
0
        // GET: LoanRequest/Edit/5
        public ActionResult Edit(Nullable <int> request)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (request == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LoanRequest loanRequest = LoanRequestServices.Get(request.Value, db);

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

            ViewBag.RequestList = new SelectList(RequestServices.List(db), "Product", "Attachment", loanRequest.Request);
            return(View(loanRequest));
        }