Ejemplo n.º 1
0
        public async void WriteToRoamingSettings(Article foundArticle)
        {
            var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

            List<string> allFavoriteSelection = new List<string>();
            string favoriteSelectionFromRoaming = (string)roamingSettings.Values["favorite"];
            if (favoriteSelectionFromRoaming != null && favoriteSelectionFromRoaming != "")
            {
                allFavoriteSelection = await JsonConvert.DeserializeObjectAsync<List<string>>(favoriteSelectionFromRoaming);
            }

            allFavoriteSelection.Add(foundArticle.ObjectId);
            roamingSettings.Values["favorite"] = await JsonConvert.SerializeObjectAsync(allFavoriteSelection);
            await new MessageDialog("Успешно добавяне.").ShowAsync();
        }
Ejemplo n.º 2
0
        public async Task<Article> GetArticleByObjectId(string id)
        {
            try
            {
                ParseQuery<ParseObject> query = ParseObject.GetQuery("Articles");
                var article = await query.GetAsync(id);

                var rang = (List<object>)article["list"];

                List<Ranglist> list = new List<Ranglist>();

                foreach (var item in rang)
                {
                    var a = (Dictionary<string, object>)item;

                    Ranglist currentItem = new Ranglist();
                    currentItem.Palce = (string)a["place"];
                    currentItem.Image = (string)a["image"];
                    list.Add(currentItem);

                }

                var foundArticle = new Article()
                {
                    Content = (string)article["content"],
                    Image = (string)article["image"],
                    ObjectId = article.ObjectId,
                    Title = (string)article["title"],
                    Ranglist = list,
                };
                return foundArticle;
            }
            catch (HttpRequestException e)
            {
                new MessageDialog("Изгубена интернет връзка. Моле опитайте отново по - късно.").ShowAsync();
                return null;
            }
            catch (Exception e)
            {
                new MessageDialog("Грешка. Моля опитайте отново.").ShowAsync();
                return null;
            }
        }
Ejemplo n.º 3
0
 public async Task GetArticle(string objectId)
 {
     Article foundArticle = await this.dataService.GetArticleByObjectId(objectId);
     this.Article = foundArticle;
     this.RaisePropertyChanged("Article");
 }
Ejemplo n.º 4
0
        public async Task GetArticle()
        {
            ArticlesInGroup article = ((App)App.Current).SelectedArticle[0] as ArticlesInGroup;
            string objectId = article.ObjectId;

            Article foundArticle = await this.dataService.GetArticleByObjectId(objectId);
            this.Article = foundArticle;
            this.RaisePropertyChanged("Article");
        }