Пример #1
0
 public ActionResult Create([Bind(Include = "NOMBRE")] AREAS Model)
 {
     if (Session["MiUsuario"] != null && Session["MiTipo"] != null)
     {
         try
         {
             if (ModelState.IsValid)
             {
                 db.AREAS.Add(Model);
                 db.SaveChanges();
                 this.Response.RemoveOutputCacheItem(Url.Action("Index").ToString());
                 return(this.RedirectToAction("Index"));
             }
             else
             {
                 return(View(Model));
             }
         }
         catch (Exception ex)
         {
             this.ModelState.AddModelError("", ex);
             return(View());
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Пример #2
0
 public ActionResult Edit(int id, AREAS areas)
 {
     if (Session["MiUsuario"] != null && Session["MiTipo"] != null)
     {
         var query = (db.AREAS.Find(id));
         if (query == null)
         {
             return(this.HttpNotFound());
         }
         if (!ModelState.IsValid)
         {
             return(View(areas));
         }
         if (!TryUpdateModel(query, new string[] { "NOMBRE" }))
         {
             return(View(areas));
         }
         try
         {
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex);
             return(View(areas));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Пример #3
0
 private bool igualValores(int id, string nombre, AREAS area)
 {
     return(id == area.ID_AREA && nombre == area.NOMBRE);
 }