Beispiel #1
0
 public ActionResult AddUser(User user)
 {
     var client = new RestClient(ServerBaseUrl + "UserRoles/AddUser");
     RestRequest request = new RestRequest(Method.POST);
     request.AddObject(user);
     int intt=  client.Execute<int>(request).Data;
     return RedirectToAction("AllUsers");
 }
Beispiel #2
0
 public static int AddUser(User user)
 {
     try
     {
         UsersDBEntities db = new UsersDBEntities();
         db.Users.Add(user);
         return db.SaveChanges();
     }
     catch (Exception ex)
     {
         return -2;
     }
 }
Beispiel #3
0
        public static int AddUser(User user)
        {
            try
            {
                using (var db = new UsersDBContext())
                {
                    db.Users.Add(user);
                    return db.SaveChanges();
                }

            }
            catch (Exception ex)
            {
                return -2;
            }
        }
Beispiel #4
0
 public static int UpdateUser(User UpdatedUser)
 {
     UsersDBEntities db = new UsersDBEntities();
     User u = (User)(from user in db.Users
              where user.UserID == UpdatedUser.UserID
              select user);
     if (u != null)
     {
         u.FirstName = UpdatedUser.FirstName;
         u.LastName = UpdatedUser.LastName;
         u.Password = UpdatedUser.Password;
         u.UserName = UpdatedUser.UserName;
         u.EmailAddress = UpdatedUser.EmailAddress;
         return db.SaveChanges();
     }
     else
         return 0;
 }
Beispiel #5
0
Datei: Repo.cs Projekt: hsloki/HG
 public static int UpdateUser(User UpdatedUser)
 {
     return DBRepo.UpdateUser(UpdatedUser);
 }
Beispiel #6
0
Datei: Repo.cs Projekt: hsloki/HG
 public static int AddUser(User user)
 {
     return DBRepo.AddUser(user);
 }
Beispiel #7
0
        public ActionResult EditUser(User user)
        {
            // get user to update db using api.
            var client = new RestClient(ServerBaseUrl + "UserRoles/UpdateUser");
            RestRequest request = new RestRequest(Method.POST);
            request.AddObject(user);
            var response = client.Execute(request);

            return RedirectToAction("AllUsers");
        }
Beispiel #8
0
 public static int UpdateUser(User UpdatedUser)
 {
     using (UsersDBEntities db = new UsersDBEntities())
     {
         User u = db.Users.Single(user => user.UserID == UpdatedUser.UserID);
         if (u != null)
         {
             u.FirstName = UpdatedUser.FirstName;
             u.LastName = UpdatedUser.LastName;
             u.Password = UpdatedUser.Password;
             u.UserName = UpdatedUser.UserName;
             u.EmailAddress = UpdatedUser.EmailAddress;
             return db.SaveChanges();
         }
         else
             return 0;
     }
 }