/// <summary> /// Inserts a new User /// </summary> /// <returns>the inserted user's id</returns> public override void Insert(User user) { if (user == null) { throw new ArgumentNullException("user"); } if (Exists(user.Username)) { throw new Exception(String.Format("User {0} already exists.", user.Username)); } // insert the user DAL.User newUser = new DAL.User { Enabled = user.Enabled, Password = user.Password, Role = ((short)user.Role), Username = user.Username }; newUser.Save(); // add user profile _profileController.Insert(newUser.Id, user.FirstName, user.LastName, user.Address, user.City, user.State, user.ZipCode, user.PhoneNumber, user.Email); // update the passed in user object user.ID = newUser.Id; // assign the user to a manager if (user.ManagerID > 0) { AssignManager(user.ID, user.ManagerID); } }
/// <summary> /// Updates the enabled. /// </summary> /// <param name="id">The id.</param> /// <param name="enabled">if set to <c>true</c> [enabled].</param> /// <returns></returns> public void Enable(int id, bool enabled) { DAL.User user = new DAL.User(id) { Enabled = enabled }; user.Save(); }
public Boolean Save() { try { Boolean status = false; if (Password == ReTypePassword) { user = new DAL.User(); PopulateDataLayer(); user.Save(); MessageBox.Show("Username and Password Save!", "Record Save"); status = true; } else { MessageBox.Show("Password not match"); } return(status); } catch (Exception ex) { throw ex; } }
internal long Save(BE.User user) { return(_storage.Save(user)); }