Exemplo n.º 1
0
    public static bool UpdateUser(this DBEntities DB, UserView userView)
    {
        userView.SaveAvatar();
        User userToUpdate = DB.Users.Find(userView.Id);

        userView.CopyToUser(userToUpdate);
        DB.Entry(userToUpdate).State = EntityState.Modified;
        DB.SaveChanges();
        return(true);
    }
Exemplo n.º 2
0
 public ActionResult Profil(UserView userView)
 {
     if (ModelState.IsValid)
     {
         string PasswordChangeToken = (string)Request["PasswordChangeToken"];
         User   user = DB.FindByUserName(OnlineUsers.Find(userView.Id).UserName);
         if (userView.NewPassword.Equals(PasswordChangeToken))
         {
             userView.Password = user.Password;
         }
         else
         {
             userView.Password = userView.NewPassword;
         }
         DB.UpdateUser(userView);
         userView.CopyToUser(OnlineUsers.GetSessionUser());
     }
     return(RedirectToAction("Profil"));
 }