public ActionResult Agregar(locales loc)
        {
            ctx = new AlimentoVelozEntities2();
            var exist = ctx.locales.Find(loc.id_local);
            var gnt   = ctx.gerente.Find(loc.id_gerente);

            if (exist == null)
            {
                if (gnt != null)
                {
                    ctx = new AlimentoVelozEntities2();
                    ctx.locales.Add(loc);
                    ctx.SaveChanges();
                    TempData["shortMessage"] = "Usuario Agregado Exitosamente";
                    return(RedirectToAction("ListaLocales"));
                }
                else
                {
                    ViewBag.ErrorMessage = "el ID de gerente ingresado no existe";
                    return(View());
                }
            }
            else
            {
                ViewBag.ErrorMessage = "el ID que está ingresando ya existe";
                return(View());
            }
        }
 public ActionResult DeleteConfirmed(String id)
 {
     ctx = new AlimentoVelozEntities2();
     if (id != null)
     {
         var loc = ctx.locales.Find(id);
         if (loc != null)
         {
             try
             {
                 ctx.locales.Remove(loc);
                 ctx.SaveChanges();
                 TempData["shortMessage"] = "Local borrado con Exito";
                 return(RedirectToAction("ListaLocales"));
             }
             catch
             {
                 TempData["shortMessage"] = "No se pudo completar la operacion";
                 return(RedirectToAction("ListaLocales"));
             }
         }
         else
         {
             TempData["shortMessage"] = "El ID que està tratando de eliminar no existe";
             return(RedirectToAction("ListaLocales"));
         }
     }
     else
     {
         TempData["shortMessage"] = "El ID que està tratando de eliminar no existe";
         return(RedirectToAction("ListaLocales"));
     }
 }
Пример #3
0
 public ActionResult DeleteConfirmed(String id)
 {
     ctx = new AlimentoVelozEntities2();
     if (id == null)
     {
         TempData["shortMessage"] = "el id no puede ser null o ya no existe";
         return(RedirectToAction("Index"));
     }
     else
     {
         var gnt = ctx.gerente.Find(id);
         if (gnt == null)
         {
             TempData["shortMessage"] = "el id ya no existe";
             return(RedirectToAction("Index"));
         }
         else
         {
             try
             {
                 ctx.gerente.Remove(gnt);
                 ctx.SaveChanges();
                 TempData["shortMessage"] = "Gerente eliminado con exito";
                 return(RedirectToAction("Index"));
             }
             catch
             {
                 TempData["shortMessage"] = "No se pudo completar la operacion";
                 return(RedirectToAction("Index"));
             }
         }
     }
 }
 public ActionResult Editar(locales loc)
 {
     ctx = new AlimentoVelozEntities2();
     ctx.Entry(loc).State = EntityState.Modified;
     ctx.SaveChanges();
     TempData["shortMessage"] = "Guardado Exitoso";
     return(RedirectToAction("ListaLocales"));
 }
Пример #5
0
 public ActionResult Editar(gerente gnt)
 {
     ctx = new AlimentoVelozEntities2();
     ctx.Entry(gnt).State = EntityState.Modified;
     ctx.SaveChanges();
     TempData["shortMessage"] = "Guardado Exitoso";
     return(RedirectToAction("Index"));
 }
Пример #6
0
        public ActionResult Agregar(gerente gnt)
        {
            ctx = new AlimentoVelozEntities2();
            var exist = ctx.gerente.Find(gnt.id_gerente);

            if (exist == null)
            {
                ctx = new AlimentoVelozEntities2();
                ctx.gerente.Add(gnt);
                ctx.SaveChanges();
                TempData["shortMessage"] = "Gerente Agregado Exitosamente";
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.ErrorMessage = "el ID que está ingresando ya existe";
                return(View());
            }
        }