Пример #1
0
 public ActionResult Agregar(Categoria categoria)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Categorias.Add(categoria);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch (Exception ex)
     {
         TempData["Error"] = ex.Message;
         return View("Error");
     }
 }
Пример #2
0
 public ActionResult Editar(Categoria categoria)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(categoria).State = EntityState.Modified;
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch (Exception ex)
     {
         TempData["Error"] = ex.Message;
         return View("Error");
     }
 }
Пример #3
0
 public ActionResult Agregar()
 {
     Categoria categoria = new Categoria();
     return View(categoria);
 }