public async void Register(string email, string password)
        {
            var loader  = new ResourceLoader();
            var newUser = new User()
            {
                Email = email, Password = password
            };
            var status = await _httpService.CreateAccount(newUser);

            switch (status)
            {
            case 204:
                _userDataStorageService.AddUserData("ASPassword", email, password);
                _httpService.SetAuthenticationHeader(email, password);
                _eventAggregator.PublishOnUIThread(new RegisterSuccessEvent()
                {
                    SuccessMessage = loader.GetString("RegisterSuccessMessage")
                });
                break;

            case 422:
                _eventAggregator.PublishOnUIThread(new RegisterFailedEvent()
                {
                    FailMessage = loader.GetString("RegisterEmailFailMessage")
                });
                break;

            default:
                _eventAggregator.PublishOnUIThread(new RegisterFailedEvent()
                {
                    FailMessage = loader.GetString("ServerError")
                });
                break;
            }
        }
Esempio n. 2
0
        public async Task <bool> Login(User user)
        {
            var status = await _httpService.Login(user);

            var    isConnected = false;
            string email       = user.Email;
            string password    = user.Password;

            switch (status)
            {
            case 200:
                _userDataStorageService.AddUserData("Uzytkownik", email, password);
                _httpService.SetAuthenticationHeader(email, password);
                isConnected = true;
                break;

            case 401:
                break;

            default:
                break;
            }

            return(isConnected);
        }