public static UserModel EditUser(string sessionKey, UserEditModel editedUser)
        {
            ValidateUsername(editedUser.Username);
            if (editedUser.OldPasswordHash!=null)
            {
                ValidateAuthCode(editedUser.NewPasswordHash);
            }
            headers[HttpRequester.sessionKeyHeaderName] = sessionKey;
            UserModel result = HttpRequester.
                Post<UserModel>(baseUrl + "users/edit", editedUser,headers);

            return result;
        }
        private void HandleEditProfileCommand(object parameter)
        {

            if ((this.NewPassword == null || this.NewPassword.Length < 2) && this.OldPassword!=null)
            {
                ErrorMessage = "Invalid new password";
                SuccessMessage = "";
                OnPropertyChanged("ErrorMessage");
                OnPropertyChanged("SuccessMessage");
            }
            else
            {
                try
                {
                    var editProfile = new UserEditModel()
                    {
                        Id = CurrentUserSettings.Id,
                        Username = Username,
                        FirstName = FirstName,
                        LastName = LastName,
                        ProfilePictureUrl = ProfilePictureUrl
                    };

                    if (this.OldPassword != null)
                    { 
                        editProfile.OldPasswordHash = Sha1Encrypter.CalculateSHA1(OldPassword);
                        editProfile.NewPasswordHash = Sha1Encrypter.CalculateSHA1(NewPassword);
                    }

                    this.CurrentUserSettings = UserPersister.EditUser(CurrentUserSettings.SessionKey, editProfile);
                    this.FirstName = this.CurrentUserSettings.FirstName;
                    this.LastName = this.CurrentUserSettings.LastName;
                    
                    this.OldPassword = "";
                    this.NewPassword = "";
                    OnPropertyChanged("OldPassword");
                    OnPropertyChanged("NewPassword");
                    OnPropertyChanged("FirstName");
                    OnPropertyChanged("LastName");

                    ErrorMessage = "";
                    SuccessMessage = "Profile updated successfully";
                    OnPropertyChanged("ErrorMessage");
                    OnPropertyChanged("SuccessMessage");
                    RaiseEditSuccess(CurrentUserSettings);
                }
                catch (Exception ex)
                {
                    ErrorMessage = "Could not edit profile";
                    SuccessMessage = "";
                    OnPropertyChanged("ErrorMessage");
                    OnPropertyChanged("SuccessMessage");
                }

            }
        }