Ejemplo n.º 1
0
 public ActionResult EditUser(int id, User _user)
 {
     try
     {
         using (dbMayapadaEntities dc = new dbMayapadaEntities())
         {
             dc.Entry(_user).State = EntityState.Modified;
             dc.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 2
0
 public ActionResult CreateUser(User _user)
 {
     try
     {
         using (dbMayapadaEntities dc = new dbMayapadaEntities())
         {
             dc.Users.Add(_user);
             dc.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 3
0
        public ActionResult DeleteUser(int id, FormCollection collection)
        {
            try
            {
                using (dbMayapadaEntities dc = new dbMayapadaEntities())
                {
                    var result = dc.Users.Where(a => a.UserId == id).FirstOrDefault();

                    User user = dc.Users.Where(a => a.UserId == id).FirstOrDefault();
                    dc.Users.Remove(user);
                    dc.SaveChanges();

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