public ActionResult Edit(int id = 1) { CurrentGood = BusinessGoods.FirstOrDefault(x => x.GoodId == id); var model = CurrentGood; return(View(model)); }
public AdminController() { context = new ShopContext(); CurrentGood = new BusinessGood(); if (BusinessGoods == null) { BusinessGoods = new List <BusinessGood>(); BusinessGood.Autofill(BusinessGoods); } }
public ActionResult Add(BusinessGood a) { if (ModelState.IsValid) { BusinessGoods.Add(a); BusinessGood.AddOrUpdate(a); return(RedirectToAction("Index" /*,new { id = (int)Session["page"]}*/)); } else { return(View(a)); } }
public ActionResult Edit(BusinessGood a) { if (ModelState.IsValid) { int index = BusinessGoods .IndexOf(BusinessGoods.FirstOrDefault(x => x.GoodId == a.GoodId)); BusinessGoods[index] = a; BusinessGood.AddOrUpdate(a); return(RedirectToAction("Index" /*,new { id = (int)Session["page"]}*/)); } else { return(View(a)); } }
public ActionResult Remove(int id) { BusinessGood.Remove(BusinessGoods.FirstOrDefault(x => x.GoodId == id)); BusinessGoods.Remove(BusinessGoods.FirstOrDefault(x => x.GoodId == id)); return(RedirectToAction("GetTableGoods")); }
public ClientController() { context = new ShopContext(); BusinessGoods = new List <BusinessGood>(); BusinessGood.Autofill(BusinessGoods); }