public ActionResult Create([Bind(Include = "Grant, Amount, Description")] GrantDeduction grantDeduction) { Db db = new Db(DbServices.ConnectionString); if (ModelState.IsValid) { try { GrantDeductionServices.Insert(CurrentUser.Id, grantDeduction, 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.GrantList = new SelectList(GrantServices.List(db), "Product", "Name"); return(View(grantDeduction)); }
// GET: GrantDeduction/Delete/5 public ActionResult Delete(Nullable <int> id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Db db = new Db(DbServices.ConnectionString); GrantDeduction grantDeduction = GrantDeductionServices.Get(id.Value, db); if (grantDeduction == null) { return(HttpNotFound()); } return(View(grantDeduction)); }
// GET: GrantDeduction/Edit/5 public ActionResult Edit(Nullable <int> grant) { Db db = new Db(DbServices.ConnectionString); if (grant == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GrantDeduction grantDeduction = GrantDeductionServices.Get(grant.Value, db); if (grantDeduction == null) { return(HttpNotFound()); } ViewBag.GrantList = new SelectList(GrantServices.List(db), "Product", "Name", grantDeduction.Grant); return(View(grantDeduction)); }
public ActionResult DeleteConfirmed(int grant) { try { Db db = new Db(DbServices.ConnectionString); GrantDeductionServices.Delete(CurrentUser.Id, grant, 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(grantDeduction); return(RedirectToAction("Index")); }