public static async Task<UserModel> Login(string username, string passwordHash)
        {
            var user = new UserModel() {Username = username, PasswordHash = passwordHash};
            var response = await HttpRequester.Post<UserModel>(baseUrl + "login", user);

            return response;
        }
        private async void HandleRegister(object obj)
        {
            var passwordBox = obj as PasswordBox;
            var password = passwordBox.Password;

            if(string.IsNullOrEmpty(Username) || string.IsNullOrWhiteSpace(Username))
            {
                ErrorMessage = "Enter a username";
                return;
            }

            if (string.IsNullOrEmpty(password) || string.IsNullOrWhiteSpace(password))
            {
                ErrorMessage = "Enter a password";
                return;
            }

            if (string.IsNullOrEmpty(FirstName) || string.IsNullOrWhiteSpace(FirstName))
            {
                ErrorMessage = "Enter a first name";
                return;
            }

            if (string.IsNullOrEmpty(LastName) || string.IsNullOrWhiteSpace(LastName))
            {
                ErrorMessage = "Enter a last name";
                return;
            }

            Registering = true;
            OnPropertyChanged("Registering");

            var passwordHash = Sha1Encrypter.ConvertToSha1(password);

            var userModel = new UserModel()
                                {
                                    Username = Username,
                                    PasswordHash = passwordHash,
                                    FirstName = FirstName,
                                    LastName = LastName,
                                    ProfilePictureUrl = ProfilePictureUrl
                                };

            var loggedUser = await UsersPersister.Register(userModel);
            if (loggedUser != null)
            {
                AccountManager.CurrentUser = loggedUser;

                NavigationService.Navigate(ViewType.Home);
            }
            else
            {
                Registering = false;
                OnPropertyChanged("Registering");
                ErrorMessage = "Cannot register user";
            }
        }
 public static async Task<UserModel> Register(UserModel model)
 {
     var response = await HttpRequester.Post<UserModel>(baseUrl + "register", model);
     return response;
 }