Beispiel #1
0
        public ActionResult Create([Bind(Include = "Product, PaymentPeriod, Installment, NetAmount, ProfitAmount, SyrianPoundRounds")] RefundableProduct refundableProduct)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    RefundableProductServices.Insert(CurrentUser.Id, refundableProduct, 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.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes");
            return(View(refundableProduct));
        }
        public ActionResult Create([Bind(Include = "Id, RefundableProduct, SubNumber, Employee, GuarantorStatus, Notes")] Guarantor guarantor)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    GuarantorServices.Insert(CurrentUser.Id, guarantor, 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.EmployeeList          = new SelectList(EmployeeServices.List(db), "Id", "FirstName");
            ViewBag.GuarantorStatusList   = new SelectList(GuarantorStatusServices.List(db), "Id", "Name");
            ViewBag.RefundableProductList = new SelectList(RefundableProductServices.List(db), "Product", "Name");
            return(View(guarantor));
        }
        public ActionResult Create([Bind(Include = "Id, RefundableProduct, SubNumber, DueDate, DueCapital, DueProfit, Notes")] Installment installment)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    InstallmentServices.Insert(CurrentUser.Id, installment, 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.RefundableProductList = new SelectList(RefundableProductServices.List(db), "Product", "Name");
            return(View(installment));
        }
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.RefundableProductList = new SelectList(RefundableProductServices.List(db), "Product", "Name");
            return(View());
        }
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.EmployeeList          = new SelectList(EmployeeServices.List(db), "Id", "FirstName");
            ViewBag.GuarantorStatusList   = new SelectList(GuarantorStatusServices.List(db), "Id", "Name");
            ViewBag.RefundableProductList = new SelectList(RefundableProductServices.List(db), "Product", "Name");
            return(View());
        }
        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));
        }
Beispiel #7
0
        // GET: RefundableProduct/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db db = new Db(DbServices.ConnectionString);
            RefundableProduct refundableProduct = RefundableProductServices.Get(id.Value, db);

            if (refundableProduct == null)
            {
                return(HttpNotFound());
            }
            return(View(refundableProduct));
        }
Beispiel #8
0
        // GET: RefundableProduct/Edit/5
        public ActionResult Edit(Nullable <int> product)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (product == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RefundableProduct refundableProduct = RefundableProductServices.Get(product.Value, db);

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

            ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes", refundableProduct.Product);
            return(View(refundableProduct));
        }
        // GET: Installment/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Installment installment = InstallmentServices.Get(id.Value, db);

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

            ViewBag.RefundableProductList = new SelectList(RefundableProductServices.List(db), "Product", "Name", installment.RefundableProduct);
            return(View(installment));
        }
Beispiel #10
0
 public ActionResult DeleteConfirmed(int product)
 {
     try
     {
         Db db = new Db(DbServices.ConnectionString);
         RefundableProductServices.Delete(CurrentUser.Id, product, 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(refundableProduct);
     return(RedirectToAction("Index"));
 }
        // GET: Guarantor/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Guarantor guarantor = GuarantorServices.Get(id.Value, db);

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

            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));
        }
        public ActionResult Edit(LoanRequestViewModel model)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    EmployeeProductCalculatorFilter f = new EmployeeProductCalculatorFilter();
                    f.EmployeeId = model.RequestProduct.Employee; f.ProductTypeId = (short)model.RequestProduct.ProductType;
                    f.Amount     = (decimal)model.Request.Amount; f.Period = (short)model.RequestProductProductRefundableProduct.PaymentPeriod;
                    List <EmployeeProductCalculatorResult> result = db.EmployeeProductCalculator(f);
                    if (result.Count > 0)
                    {
                        model.RequestProductProductRefundableProduct.NetAmount    = result[0].NetAmount.Value;
                        model.RequestProductProductRefundableProduct.ProfitAmount = result[0].ProfitAmount.Value;
                        model.RequestProductProductRefundableProduct.Installment  = result[0].Installment.Value;
                    }
                    // 1- Add Prouct
                    // set the Amount of the Produt the same as Request
                    //model.RequestProduct.Amount = model.Request.Amount;
                    ProductServices.Update(CurrentUser.Id, model.RequestProduct, db);
                    ProductServices.Update(CurrentUser.Id, model.RequestProduct, db);

                    //2-Add Request
                    //model.Request.Product = model.RequestProduct.Id;
                    // model.Request.RequestStatus = (int)RequestStatusEnum.New;
                    //model.Request.Cost = 5;
                    RequestServices.Update(CurrentUser.Id, model.Request, db);

                    //3-Add LoanRequest
                    //model.LoanRequest.Request = model.RequestProduct.Id;
                    LoanRequestServices.Update(CurrentUser.Id, model.LoanRequest, db);

                    //4- Add RefundableProduct

                    //model.RequestProductProductRefundableProduct.Product = model.RequestProduct.Id;
                    RefundableProductServices.Update(CurrentUser.Id, model.RequestProductProductRefundableProduct, db);

                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "UpdateConfirmed");

                    return(RedirectToAction("Index", "LoanRequest"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

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

            // For Request
            ViewBag.BypassStatusList  = new SelectList(BypassStatusServices.List(db), "Id", "Name", model.Request.BypassStatus);
            ViewBag.ProductList       = new SelectList(ProductServices.List(db), "Id", "Notes", model.Request.Product);
            ViewBag.RequestStatusList = new SelectList(RequestStatusServices.List(db), "Id", "Name", model.Request.RequestStatus);


            return(View(model));
        }
        public ActionResult Create(LoanRequestViewModel model)
        {
            int productId = 0;

            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
                    {
                        EmployeeProductCalculatorFilter f = new EmployeeProductCalculatorFilter();
                        f.EmployeeId = model.RequestProduct.Employee; f.ProductTypeId = (short)model.RequestProduct.ProductType;
                        f.Amount     = (decimal)model.Request.Amount; f.Period = (short)model.RequestProductProductRefundableProduct.PaymentPeriod;
                        List <EmployeeProductCalculatorResult> result = db.EmployeeProductCalculator(f);
                        if (result.Count > 0)
                        {
                            model.RequestProductProductRefundableProduct.NetAmount    = result[0].NetAmount.Value;
                            model.RequestProductProductRefundableProduct.ProfitAmount = result[0].ProfitAmount.Value;
                            model.RequestProductProductRefundableProduct.Installment  = result[0].Installment.Value;
                        }
                        // 1- Add Prouct
                        // set the Amount of the Produt the same as Request
                        model.RequestProduct.Amount = model.Request.Amount;
                        Product p = ProductServices.Insert(CurrentUser.Id, model.RequestProduct, db);
                        productId = p.Id;

                        //2-Add Request
                        model.Request.Product       = p.Id;
                        model.Request.RequestStatus = (int)RequestStatusEnum.New;
                        model.Request.Cost          = 5;
                        Request r = RequestServices.Insert(CurrentUser.Id, model.Request, db);

                        //3-Add LoanRequest
                        model.LoanRequest.Request = p.Id;
                        LoanRequestServices.Insert(CurrentUser.Id, model.LoanRequest, db);

                        //4- Add RefundableProduct

                        model.RequestProductProductRefundableProduct.Product = p.Id;
                        RefundableProductServices.Insert(CurrentUser.Id, model.RequestProductProductRefundableProduct, 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 = productId }));
            }
            catch (CfException cfex)
            {
                TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
            }
            catch (Exception ex)
            {
                TempData["Failure"] = ex.Message;
            }
            return(View());
        }