示例#1
0
        public async Task <Tuple <bool, string> > Login(string username, string password)
        {
            try
            {
                string json;

                json = await _client.login(username, password);

                if (json == "\"1\"")
                {
                    json = await _client.get_user_data(username);

                    var user = JsonConvert.DeserializeObject <User>(json);
                    user.login = username;

                    App.SetUser(user);
                    json = await _client.add_visit(username);

                    return(new Tuple <bool, string>(true, ""));
                }
                return(new Tuple <bool, string>(false, "Неверный логин или пароль"));
            }
            catch (Exception ex)
            {
                return(new Tuple <bool, string>(false, "Возникла непредвиденная ошибка. Повторите позднее"));
            }
        }