public User EditUser(User user) { // Get original user object from database, no need to assig it to a variable GetUser(user.UserId); _entities.Users.ApplyCurrentValues(user); _entities.SaveChanges(); return user; }
public bool DeleteUser(User user) { try { _userRepository.DeleteUser(user); } catch { return false; } return true; }
public bool EditUser(User user) { // Validation logic if (!ValidateUser(user)) return false; // Database logic try { _userRepository.EditUser(user); } catch { return false; } return true; }
public MembershipUser CreateUser(string username, string password, string email) { using (var entities = new BAPSLansdaleEntities()) { var user = new User(); user.UserName = username; user.PasswordSalt = CreateSalt(); user.Password = CreatePasswordHash(password, user.PasswordSalt); user.Email = email; user.LastLogin = DateTime.Now; user.Active = true; user.NeedsPasswordChange = true; user.RoleID = GetDefaultRoleId(entities); entities.AddToUsers(user); entities.SaveChanges(); return GetUser(username); } }
public void DeleteUser(User user) { _entities.Users.DeleteObject(user); _entities.SaveChanges(); }
public User CreateUser(User user) { _entities.AddToUsers(user); _entities.SaveChanges(); return user; }
public ActionResult EditUser(User user) { // Validation logic _userService.ValidateUser(user); if (!ModelState.IsValid) return View(); try { _userService.EditUser(user); return RedirectToAction("Users", "Account"); } catch { return View(); } }
public bool ValidateUser(User user) { if (user.UserName.Trim().Length == 0) _validationDictionary.AddError("UserName", "Username is required."); if (user.Password.Trim().Length == 0) _validationDictionary.AddError("Password", "Password is required."); return _validationDictionary.IsValid; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="userName">Initial value of the UserName property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="active">Initial value of the Active property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="passwordSalt">Initial value of the PasswordSalt property.</param> /// <param name="roleID">Initial value of the RoleID property.</param> /// <param name="needsPasswordChange">Initial value of the NeedsPasswordChange property.</param> public static User CreateUser(global::System.Int32 userId, global::System.String userName, global::System.String password, global::System.Boolean active, global::System.String email, global::System.String passwordSalt, global::System.Int32 roleID, global::System.Boolean needsPasswordChange) { User user = new User(); user.UserId = userId; user.UserName = userName; user.Password = password; user.Active = active; user.Email = email; user.PasswordSalt = passwordSalt; user.RoleID = roleID; user.NeedsPasswordChange = needsPasswordChange; return user; }