Пример #1
0
 public static QuizUserViewModel CreateUserModel(User user)
 {
     return new QuizUserViewModel
     {
         FirstName = user.FirstName,
         LastName = user.LastName,
         UserName = user.Username,
         EmailAddress = user.Email
     };
 }
Пример #2
0
 public static User AddUser(User newUser)
 {
     using (QuizBuilderDb db = new QuizBuilderDb())
     {
         User toAdd = newUser;
         db.Users.Add(toAdd);
         db.SaveChanges();
         return toAdd;
     }
 }
Пример #3
0
 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;
         }
     }
 }