Exemplo n.º 1
0
        public async Task <List <NewsItem> > GetCategoryNewsAsync(string categoryUrl)
        {
            List <NewsItem> newsItems        = new List <NewsItem>();
            DownloadUtil    downloadUtil     = new DownloadUtil();
            var             downloadedString = await downloadUtil.DownloadStringAsync(categoryUrl);

            if (!String.IsNullOrEmpty(downloadedString) && downloadedString.Trim() != "{}")
            {
                newsItems = Newtonsoft.Json.JsonConvert.DeserializeObject <List <NewsItem> >(downloadedString);
            }
            return(newsItems);
        }
Exemplo n.º 2
0
        public async Task <List <MyApp> > GetMyAppsAsync()
        {
            List <MyApp> listOfApps       = new List <MyApp>();
            var          myAppsUrl        = string.Format("https://thehinduadrotator.blob.core.windows.net/myapps/myapps.json");
            DownloadUtil downloadUtil     = new DownloadUtil();
            var          downloadedString = await downloadUtil.DownloadStringAsync(myAppsUrl);

            var myApps = JsonConvert.DeserializeObject <MyApps>(downloadedString);

            if (myApps != null)
            {
                listOfApps = myApps.myapps;
            }
            return(listOfApps);
        }
Exemplo n.º 3
0
        private async Task <List <Category> > LoadCategoriesAsync()
        {
            List <Category> categories       = new List <Category>();
            DownloadUtil    downloadUtils    = new DownloadUtil();
            var             categoriesString = await downloadUtils.DownloadStringAsync(Consts.DDNEWS_URL);

            var listOfCategories = Newtonsoft.Json.JsonConvert.DeserializeObject <ListOfCategories>(categoriesString);

            if (listOfCategories != null)
            {
                categories = listOfCategories.categories;
                categories.ForEach(async o => { await DatabaseOperations.Instance.UpdateCategoryAsync(o); });
            }

            if (categories == null || categories.Count == 0)
            {
                categories.Add(new Category(Consts.HEADLINES_ENG_STRING, Consts.HEADLINES_ENG_STRING, Consts.HEADLINES_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.SCIENCE_TECH_ENG_STRING, Consts.SCIENCE_TECH_ENG_STRING, Consts.SCIENCE_TECH_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.SOCIAL_ENG_STRING, Consts.SOCIAL_ENG_STRING, Consts.SOCIAL_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.NATIONAL_ENG_STRING, Consts.NATIONAL_ENG_STRING, Consts.NATIONAL_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.INTERNATIONAL_ENG_STRING, Consts.INTERNATIONAL_ENG_STRING, Consts.INTERNATIONAL_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.BUSINESS_ENG_STRING, Consts.BUSINESS_ENG_STRING, Consts.BUSINESS_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.HEALTH_ENG_STRING, Consts.HEALTH_ENG_STRING, Consts.HEALTH_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.CURRENT_ENG_STRING, Consts.CURRENT_ENG_DECORATIVE_STRING, Consts.CURRENT_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.SPORTS_ENG_STRING, Consts.SPORTS_ENG_STRING, Consts.SPORTS_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));
                categories.Add(new Category(Consts.ENTERTAINMENT_ENG_STRING, Consts.ENTERTAINMENT_ENG_STRING, Consts.ENTERTAINMENT_ENGLISH_URL, Consts.CATEGORY_ENGLISH_STRING));

                categories.Add(new Category(Consts.HEADLINES_ENG_STRING, Consts.HEADLINES_HINDI_STRING, Consts.HEADLINES_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
                categories.Add(new Category(Consts.NATIONAL_ENG_STRING, Consts.NATIONAL_HINDI_STRING, Consts.NATIONAL_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
                categories.Add(new Category(Consts.INTERNATIONAL_ENG_STRING, Consts.INTERNATIONAL_HINDI_STRING, Consts.INTERNATIONAL_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
                categories.Add(new Category(Consts.BUSINESS_ENG_STRING, Consts.BUSINESS_HINDI_STRING, Consts.BUSINESS_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
                categories.Add(new Category(Consts.CURRENT_ENG_STRING, Consts.CURRENT_HINDI_STRING, Consts.CURRENT_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
                categories.Add(new Category(Consts.SPORTS_ENG_STRING, Consts.SPORTS_HINDI_STRING, Consts.SPORTS_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
                categories.Add(new Category(Consts.ENTERTAINMENT_ENG_STRING, Consts.ENTERTAINMENT_HINDI_STRING, Consts.ENTERTAINMENT_HINDI_URL, Consts.CATEGORY_HINDI_STRING));
            }
            return(categories);
        }