public AccountEditViewModel BuildEdit(User user)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     var result = new AccountEditViewModel();
     result.FirstName = user.UserProfile.FirstName;
     result.LastName = user.UserProfile.LastName;
     result.Email = user.Email;
     result.Key = user.Key;
     result.RegistrationDate = user.UserProfile.RegistrationDate;
     return result;
 }
 public void UpdateUser(User user, AccountEditViewModel viewModel)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     if (viewModel == null)
     {
         throw new ArgumentNullException("viewModel");
     }
     user.UserProfile.FirstName = viewModel.FirstName;
     user.UserProfile.LastName = viewModel.LastName;
 }
        public ActionResult AdminEditUser(int? userKey, AccountEditViewModel viewModel)
        {
            bool result = false;

            if (this.ModelState.IsValid && viewModel != null && userKey.HasValue)
            {
                try
                {
                    User sourceUser = this._membershipService.GetUserByKey(userKey.Value);
                    if (sourceUser != null)
                    {
                        this._userAccountMapper.UpdateUser(sourceUser, viewModel);
                        this._membershipService.UpdateUser(sourceUser);
                    }

                    result = true;
                }
                catch (Exception)
                {
                    this.ModelState.AddModelError(string.Empty, Resources.Resources.OperationFailure);
                }
            }
            else
            {
                this.ModelState.AddModelError(string.Empty, Resources.Resources.OperationFailure);
            }

            if (result)
            {
                return this.Json(new { success = result });
            }

            return this.PartialView("_AdminEditUser", viewModel);
        }