public ActionResult Edit([Bind(Include = "Product, Date, Amount, Attachment, Cost, RequestStatus, BypassStatus, Notes")] Request request) { Db db = new Db(DbServices.ConnectionString); if (ModelState.IsValid) { try { RequestServices.Update(CurrentUser.Id, request, 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.BypassStatusList = new SelectList(BypassStatusServices.List(db), "Id", "Name", request.BypassStatus); ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes", request.Product); ViewBag.RequestStatusList = new SelectList(RequestStatusServices.List(db), "Id", "Name", request.RequestStatus); return(View(request)); }
public ActionResult Create() { Db db = new Db(DbServices.ConnectionString); ViewBag.BypassStatusList = new SelectList(BypassStatusServices.List(db), "Id", "Name"); ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes"); ViewBag.RequestStatusList = new SelectList(RequestStatusServices.List(db), "Id", "Name"); return(View()); }
// GET: RequestStatus/Delete/5 public ActionResult Delete(Nullable <byte> id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Db db = new Db(DbServices.ConnectionString); RequestStatus requestStatus = RequestStatusServices.Get(id.Value, db); if (requestStatus == null) { return(HttpNotFound()); } return(View(requestStatus)); }
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)); }
// GET: Request/Edit/5 public ActionResult Edit(Nullable <int> product) { Db db = new Db(DbServices.ConnectionString); if (product == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Request request = RequestServices.Get(product.Value, db); if (request == null) { return(HttpNotFound()); } ViewBag.BypassStatusList = new SelectList(BypassStatusServices.List(db), "Id", "Name", request.BypassStatus); ViewBag.ProductList = new SelectList(ProductServices.List(db), "Id", "Notes", request.Product); ViewBag.RequestStatusList = new SelectList(RequestStatusServices.List(db), "Id", "Name", request.RequestStatus); return(View(request)); }
public ActionResult DeleteConfirmed(byte id) { try { Db db = new Db(DbServices.ConnectionString); RequestStatusServices.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(requestStatus); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id, Name")] RequestStatus requestStatus) { Db db = new Db(DbServices.ConnectionString); if (ModelState.IsValid) { try { RequestStatusServices.Insert(CurrentUser.Id, requestStatus, 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; } } return(View(requestStatus)); }
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)); }