コード例 #1
0
ファイル: UserService.cs プロジェクト: vanhouc/QuizBuilderASP
 public static User UpdateUser(QuizUserViewModel updatedUser)
 {
     using (QuizBuilderDb db = new QuizBuilderDb())
     {
         User currentUser = UserService.FindByName(updatedUser.UserName);
         if (currentUser != null)
         {
             currentUser = db.Users.Find(currentUser.UserID);
             currentUser.FirstName = updatedUser.FirstName;
             currentUser.LastName = updatedUser.LastName;
             currentUser.Email = updatedUser.EmailAddress;
             db.SaveChanges();
             return currentUser;
         }
         else
         {
             return currentUser;
         }
     }
 }
コード例 #2
0
 public ActionResult UpdateUser(QuizUserViewModel model)
 {
     if (ModelState.IsValid)
     {
         UserService.UpdateUser(model);
         return RedirectToAction("Default");
     }
     else
     {
         return View("Default", model);
     }
 }