Exemple #1
0
        public static async Task <bool> loginSubmit(string username, string password, string captcha)
        {
            Models.Preferences.Token token = App.PreferenceDatabase.GetToken();
            if (token == null)
            {
                throw new Exceptions.SessionTimeoutException();
            }
            Models.GeneralReturn <Models.Responses.UserLoginSubmit> result = await DataFetch.post <Models.Responses.UserLoginSubmit>(String.Format(urlUserLoginSubmit, urlBase, token.AccessToken), new Dictionary <string, string> {
                { "username", username },
                { "password", password },
                { "captcha", captcha }
            });

            if (result.Status == 200)
            {
                if (result.Data.Success)
                {
                    token.IsLoggedIn  = true;
                    token.ValidBefore = DateTime.Now.AddMinutes(39);
                    App.PreferenceDatabase.SetToken(token);
                }
                else
                {
                    App.PreferenceDatabase.RemoveToken();
                }
                return(result.Data.Success);
            }
            else
            {
                throw new Exception(result.Return);
            }
        }
        public static async Task <Models.Schedule> fetchCurrent(string token)
        {
            Models.GeneralReturn <Models.Schedule> result = await DataFetch.post <Models.Schedule>(String.Format(urlGetScheduleCurrent, urlBase, token), new Dictionary <string, string> {
            });

            if (result.Status == 200)
            {
                return(result.Data);
            }
            else
            {
                throw new Exception(result.Return);
            }
        }
Exemple #3
0
        public static async Task <string> loginStartWithCaptcha()
        {
            Models.GeneralReturn <Models.Responses.UserLoginStart> result = await DataFetch.get <Models.Responses.UserLoginStart>(String.Format(urlUserLoginStart, urlBase));

            if (result.Status == 200)
            {
                App.PreferenceDatabase.SetToken(new Models.Preferences.Token {
                    AccessToken = result.Data.Token,
                    ValidBefore = DateTime.Now.AddMinutes(8),
                    IsLoggedIn  = false
                });
                return(result.Data.Captcha);
            }
            else
            {
                throw new Exception(result.Return);
            }
        }