Esempio n. 1
0
 // GET: Toys/Details/5
 public ActionResult Details(int id)
 {
     using (HPContext context = new HPContext())
     {
         Toys t = context.Toys.Find(id);
         return(View(t));
     }
 }
Esempio n. 2
0
        //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));
            }
        }
Esempio n. 3
0
        // 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));
            }
        }
Esempio n. 4
0
 public ActionResult Create(Toys obj)
 {
     try
     {
         using (HPContext context = new HPContext())
         {
             context.Toys.Add(obj);
             context.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 5
0
 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());
     }
 }
Esempio n. 6
0
 public CharacterRepository(HPContext context)
 {
     this.context = context ?? throw new ArgumentNullException("context");
 }