Beispiel #1
0
        private async void Login()
        {
            var AM = DependencyService.Resolve <AppModel>();
            await _client.OpenURL(Constants.BASE_URI + String.Format("user_sessions/?user_session[username]={0}&user_session[password]={1}", Username, Password), MethodEnum.POST, false);

            AM.UserSessionCookie = _client.UserSessionCookie;
            if (_client.UserSessionCookie != null)
            {
                AM.StoreCredentials(Username, Password, _client.UserSessionCookie);

                await _client.OpenURL(Constants.BASE_URI + String.Format("users/{0}/", AM.User.username), MethodEnum.GET, true);

                var user = Newtonsoft.Json.JsonConvert.DeserializeObject <UserDTO>(_client.ResponseText);
                AM.User.ID      = user.User.ID;
                AM.User.Name    = user.User.Name;
                AM.User.Email   = user.User.Email;
                AM.User.Bio     = user.User.Bio;
                AM.User.Website = user.User.Website;

                Barrel.Current.Add(key: nameof(AppModel), data: AM, expireIn: TimeSpan.FromDays(1));

                await Shell.Current.GoToAsync("..?refresh=true");

                _hub.PublishAsync <LoggedInMessage>(new LoggedInMessage());
            }
            else
            {
                var forgot = await Shell.Current.DisplayAlert("Sorry", "Your username and/or password were not recognized.", "Reset Password", "Try Again");

                if (forgot)
                {
                    Device.OpenUri(new Uri("http://www.whitepaperbible.org"));
                }
            }
        }
Beispiel #2
0
        private async void FetchPapers()
        {
            //if (!Barrel.Current.IsExpired(key: url))
            //{
            //    return Barrel.Current.Get<IEnumerable<Monkey>>(key: url);
            //}
            //else
            //{

            //}

            await _client.OpenURL(Constants.BASE_URI + "cmd/home.json?caller=wpb-iPhone");

            var payload = Newtonsoft.Json.JsonConvert.DeserializeObject <Payload>(_client.ResponseText);
            var papers  = new List <PaperNode>(payload.papers);

            var AM = DependencyService.Resolve <AppModel>();

            AM.Papers = new List <Paper>();
            foreach (var node in papers)
            {
                AM.Papers.Add(node.paper);
            }

            Barrel.Current.Add(key: nameof(AppModel), data: AM, expireIn: TimeSpan.FromDays(1));

            Papers = new ObservableCollection <Paper>(AM.Papers);
        }
Beispiel #3
0
        private async void FetchPapers()
        {
            var AM = DependencyService.Resolve <AppModel>();

            if (!AM.IsLoggedIn)
            {
                await Shell.Current.GoToAsync("login");
            }
            else
            {
                await _client.OpenURL(Constants.BASE_URI + "favorite/index/?caller=wpb-iPhone", MethodEnum.GET, true);

                var papers = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PaperNode> >(_client.ResponseText);

                AM.Favorites = new List <Paper>();
                foreach (var node in papers)
                {
                    AM.Favorites.Add(node.paper);
                }

                Barrel.Current.Add(key: nameof(AppModel), data: AM, expireIn: TimeSpan.FromDays(1));

                Papers = new ObservableCollection <Paper>(AM.Favorites);
            }
        }
Beispiel #4
0
        async void PerformSearch()
        {
            //var args = new GetBibleSearchResultsInvokerArgs(SearchBar.Text, (int)SearchBar.SelectedScopeButtonIndex);
            //DoSearch.Invoke(args);

            //SearchBar.ResignFirstResponder();
            if (scope is SearchScopeEnum.Reference)
            {
                await _client.OpenURL(Constants.BASE_URI + String.Format("search/by_reference.json?keywords={0}&caller=wpb-iPhone", SearchTerms));
            }
            else if (scope is SearchScopeEnum.Keyword)
            {
                await _client.OpenURL(Constants.BASE_URI + String.Format("search/by_keyword.json?keywords={0}&caller=wpb-iPhone", SearchTerms));
            }
            else
            {
                await _client.OpenURL(Constants.BASE_URI + String.Format("search/by_phrase.json?keywords={0}&caller=wpb-iPhone", SearchTerms));
            }

            var payload = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ReferenceNode> >(_client.ResponseText);

            Results = payload;
        }
        private async void Fetch()
        {
            var AM = DependencyService.Resolve <AppModel>();

            await _client.OpenURL(Constants.BASE_URI + "papers/tagged/" + AM.CurrentTag.name + ".json?caller=wpb-iPhone");

            var paperNodes = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PaperNode> >(_client.ResponseText);

            var p = new ObservableCollection <Paper>();

            foreach (var node in paperNodes)
            {
                p.Add(node.paper);
            }

            Papers = p;
        }
Beispiel #6
0
        private async void Fetch()
        {
            await _client.OpenURL(Constants.BASE_URI + "tag.json?caller=wpb-iPhone");

            var tags = Newtonsoft.Json.JsonConvert.DeserializeObject <List <TagNode> >(_client.ResponseText);

            var AM = DependencyService.Resolve <AppModel>();

            AM.Tags = new List <Tag>();
            foreach (var node in tags)
            {
                AM.Tags.Add(node.tag);
            }

            Barrel.Current.Add(key: nameof(AppModel), data: AM, expireIn: TimeSpan.FromDays(365));

            Tags = new ObservableCollection <Tag>(AM.Tags);
        }