Ejemplo n.º 1
0
 public ActionResult Create(Category collection)
 {
     try
     {
         // TODO: Add insert logic here
         db.Category.Add(collection);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 2
0
        public ActionResult Delete(int id, Category collection)
        {
            try
            {
                // TODO: Add delete logic here
                Category obj = db.Category.FirstOrDefault(x => x.CategoryId == id);
                db.Category.Remove(obj);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, Category collection)
        {
            try
            {
                // TODO: Add update logic here
                Category obj = db.Category.FirstOrDefault(x => x.CategoryId == id);

                obj.Name = collection.Name;

                db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }