Пример #1
0
        public static User GetInstance()
        {
            if (_reference == null)
            {
                _reference = new User();
            }

            return _reference;
        }
Пример #2
0
 public async Task LogOut()
 {
     HttpResponseMessage response = await _client.GetAsync("logout/" + this.loggedInUser.SessionToken);
     if (response.IsSuccessStatusCode)
     {
         this.loggedInUser = null;
         this.inbox = null;
         this.sent = null;
         this.selectedIndex = -1;
         this.inboxAlreadyLoaded = false;
         this.sentAlreadyLoaded = false;
     }
     else
     {
         throw new Exception(errorMessage + " Try to log out again in a moment.");
     }
 }
Пример #3
0
        public async Task LogIn(string username, string password)
        {
            string encryptedUsername = encrypt(username);
            string encryptedPassword = encrypt(password);

            this.loggedInUser = new User(encryptedUsername, encryptedPassword);
            HttpResponseMessage response = await _client.GetAsync("login/" + loggedInUser.Username + "/" + loggedInUser.Password);
            if (response.IsSuccessStatusCode)
            {
                this.loggedInUser.SessionToken = await response.Content.ReadAsStringAsync();
                Console.WriteLine("@@@@@@@@@@@@@@@@@@@@Token greg: " + this.loggedInUser.SessionToken);
            }
            else
            {
                Console.WriteLine(response.IsSuccessStatusCode);
                throw new Exception(errorMessage + " Try to log in again in a moment.");
            }
        }