Beispiel #1
0
        public ActionResult Editar(AspNetUserRoles a)

        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new UsuarioContext())
                {
                    AspNetUserRoles user = db.AspNetUserRoles.Find(a.UserId, a.RoleId);

                    user.RolesName = a.RolesName;
                    db.SaveChanges();


                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
 // GET: Roles
 public ActionResult Index()
 {
     UsuarioContext db = new UsuarioContext();
     {
         return(View(db.AspNetUserRoles.ToList()));
     }
 }
 public ActionResult Detalles(int Id)
 {
     using (var db = new UsuarioContext())
     {
         AspNetUsers Pro = db.AspNetUsers.Find(Id);
         return(View(Pro));
     }
 }
Beispiel #4
0
 public ActionResult Eliminar(string Id, string id2)
 {
     using (var db = new UsuarioContext())
     {
         AspNetUserRoles Pro = db.AspNetUserRoles.Find(Id, id2);
         db.AspNetUserRoles.Remove(Pro);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Eliminar(int Id)
 {
     using (var db = new UsuarioContext())
     {
         AspNetUsers Pro = db.AspNetUsers.Find(Id);
         db.AspNetUsers.Remove(Pro);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Beispiel #6
0
 public ActionResult Editar(string Id, string Id2)
 {
     try
     {
         using (var db = new UsuarioContext())
         {
             AspNetUserRoles pro = db.AspNetUserRoles.Find(Id, Id2);
             return(View(pro));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 public ActionResult Editar(int Id)
 {
     try
     {
         using (var db = new UsuarioContext())
         {
             AspNetUsers Pro = db.AspNetUsers.Find(Id);
             return(View(Pro));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Beispiel #8
0
        public ActionResult Agregar(AspNetUserRoles a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (UsuarioContext db = new UsuarioContext())
                {
                    if (a.RoleId == "1")
                    {
                        a.RolesName = "Administrador";
                    }
                    if (a.RoleId == "2")
                    {
                        a.RolesName = "Usuario";
                    }
                    else if (a.RoleId == "3")
                    {
                        a.RolesName = "Seguridad";
                    }
                    else if (a.RoleId == "4")
                    {
                        a.RolesName = "Gestion";
                    }

                    db.AspNetUserRoles.Add(a);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("error agregar", ex);
                return(View());
            }
        }
        public ActionResult Agregar(AspNetUsers a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (UsuarioContext db = new UsuarioContext())
                {
                    db.AspNetUsers.Add(a);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("error agregar", ex);
                return(View());
            }
        }
        public ActionResult Editar(AspNetUsers a)

        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                using (var db = new UsuarioContext())
                {
                    AspNetUsers user = db.AspNetUsers.Find(a.Id);
                    user.Email    = a.Email;
                    user.UserName = a.UserName;

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }