示例#1
0
        public async Task <LoggedBlock> GetLoggedBlockInfo(CancellationToken token)
        {
            (int Code, string Response)res;
            try
            {
                res = await App.Current.WebClient.SendAsync(HttpMethod.Get, new Uri(Config.Uri.ProfileUrl), token, null);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch
            {
                throw new Exception();
            }

            switch (res.Code)
            {
            case 200:
                var model = new Models.Auth.LoggedBlock();
                if (!model.FromJson(res.Response))
                {
                    throw new Exception();
                }

                return(model);

            default:
                throw new Exception();
            }
        }
示例#2
0
        public LoggedBlockViewModel()
        {
            Model = new Models.Auth.LoggedBlock();

            if (App.Current.AuthService.IsLogged)
            {
                Load();
            }

            MessagingCenter.Subscribe <Services.Auth.AuthService>(this, "Auth", auth =>
            {
                if (auth.IsLogged)
                {
                    Load();
                }
            });
        }