/// <summary> /// Add a user to the database /// </summary> /// <param name="newUser">The user data to be inserted into the database</param> /// <returns>Returns the user back to the caller of the method</returns> public User Create(User newUser) { using (var session = _documentStore.OpenSession()) { session.Store(newUser); session.SaveChanges(); } return newUser; }
/// <summary> /// Update the details about the user /// </summary> /// <param name="someFeat"></param> /// <returns></returns> public User Update(User userDetails) { using (var session = _documentStore.OpenSession()) { session.Store(userDetails); session.SaveChanges(); } return userDetails; }
/// <summary> /// Adds a brand new user to the database /// </summary> /// <param name="userDetails"></param> /// <returns></returns> public bool CreateUser(User userDetails) { // Flag to say whether the user was created or not var userCreated = false; // Try to pull down a user with that username var someUser = _userRepository.Read(userDetails.Username); // If there isn't a user in the database by that username if (null == someUser) { // Add the user to the database, and then populate the // object with the unique id userDetails = _userRepository.Create(userDetails); userCreated = true; } // Return whether the user was created or not return userCreated; }