// GET: Toys/Details/5 public ActionResult Details(int id) { using (HPContext context = new HPContext()) { Toys t = context.Toys.Find(id); return(View(t)); } }
//private ShoppingCartModel cart = new ShoppingCartModel(); // GET: Toys public ActionResult Index() { using (HPContext context = new HPContext()) { var list = context.Toys.OrderBy(x => x.Id).ToList(); return(View(list)); } }
// GET: Toys/Delete/5 public ActionResult Delete(int id) { Toys result = null; using (HPContext context = new HPContext()) { result = context.Toys.Find(id); return(View(result)); } }
public ActionResult Create(Toys obj) { try { using (HPContext context = new HPContext()) { context.Toys.Add(obj); context.SaveChanges(); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Edit(int id, FormCollection collection) { try { using (HPContext context = new HPContext()) { var t = context.Toys.Find(id); TryUpdateModel(t); context.SaveChanges(); return(RedirectToAction("Index")); } } catch { return(View()); } }
public CharacterRepository(HPContext context) { this.context = context ?? throw new ArgumentNullException("context"); }