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"); }
public static int AddUser(User user) { try { UsersDBEntities db = new UsersDBEntities(); db.Users.Add(user); return db.SaveChanges(); } catch (Exception ex) { return -2; } }
public static int AddUser(User user) { try { using (var db = new UsersDBContext()) { db.Users.Add(user); return db.SaveChanges(); } } catch (Exception ex) { return -2; } }
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; }
public static int UpdateUser(User UpdatedUser) { return DBRepo.UpdateUser(UpdatedUser); }
public static int AddUser(User user) { return DBRepo.AddUser(user); }
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"); }
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; } }