public ActionResult ChangeName(ProfileViewModel model)
 {
     if (ModelState.IsValidField("Name"))
     {
         BllUser user = _userService.GetUserById(model.Id);
         user.Name = model.Name;
         _userService.UpdateUser(user);
     }
     return RedirectToAction("Index", new { id = model.Id });
 }
 public ActionResult ChangePassword(ProfileViewModel model)
 {
     if (ModelState.IsValidField("Password") && ModelState.IsValidField("ConfirmPassword"))
     {
         BllUser user = _userService.GetUserById(model.Id);
         user.Password = model.Password;
         _userService.UpdateUser(user);
     }
     return RedirectToAction("Index", new { id = model.Id });
 }
 public ActionResult ChangeProfilePhoto(ProfileViewModel model)
 {
     if (ModelState.IsValidField("File"))
     {
         Image image = new Bitmap(model.File.InputStream, false);
         BllUser user = _userService.GetUserByEmail(User.Identity.Name);
         byte[] bytes = _userService.ConvertToBytes(image);
         user.Avatar = bytes;
         _userService.UpdateUser(user);
     }
     return RedirectToAction("Index", new { id = model.Id });
 }
 public ActionResult ChangeEmail(ProfileViewModel model)
 {
     if (ModelState.IsValidField("Email"))
     {
         BllUser user = _userService.GetUserById(model.Id);
         user.Email = model.Email;
         if (_userService.GetUserByEmail(User.Identity.Name).Id == model.Id)
         {
             FormsAuthentication.SignOut();
             FormsAuthentication.SetAuthCookie(user.Email, true);
         }
         _userService.UpdateUser(user);
     }
     return RedirectToAction("Index", new {id = model.Id});
 }