public static QuizUserViewModel CreateUserModel(User user) { return new QuizUserViewModel { FirstName = user.FirstName, LastName = user.LastName, UserName = user.Username, EmailAddress = user.Email }; }
public static User AddUser(User newUser) { using (QuizBuilderDb db = new QuizBuilderDb()) { User toAdd = newUser; db.Users.Add(toAdd); db.SaveChanges(); return toAdd; } }
public static User UpdateUser(User updatedUser) { using (QuizBuilderDb db = new QuizBuilderDb()) { User currentUser = db.Users.Find(updatedUser.UserID); if (currentUser != null) { currentUser.FirstName = updatedUser.FirstName; currentUser.LastName = updatedUser.LastName; currentUser.Email = updatedUser.Email; db.SaveChanges(); return currentUser; } else { return currentUser; } } }