Exemple #1
0
 public PostDataItem(String uniqueId, String title, String imagePath, String content, PostDataGroup group, Uri videoPath, int page)
     : base(uniqueId, title, imagePath)
 {
     this.Content = content;
     this.Group = group;
     this.VideoPath = videoPath;
     this.Page = page;
 }
Exemple #2
0
        public static async Task<List<PostDataItem>> Find(string query)
        {
            List<PostDataItem> items = _postDataSource.AllGroups.SelectMany(group => group.Items).Where((item) => item.Content.Contains(query) || item.Title.Contains(query)).ToList();

            List<Posts> posts = await PostsDal.Find(query);

            foreach (Posts post in posts)
            {
                var group = new PostDataGroup(post.Post_Categories.First().Category_Id.ToString(),
                        post.Post_Categories.First().Category_Title,
                        "Assets/DarkGray.png",
                        1);

                //if (_postDataSource._allGroups.Where(g => g.UniqueId == group.UniqueId).Count() == 0)
                    //_postDataSource._allGroups.Add(group);
                //else
                    group = GetGroup(post.Post_Categories.First().Category_Id.ToString());

                string content = WebUtility.HtmlDecode(Regex.Replace(post.Post_Content, @"<[^>]*>", String.Empty));
                string title = WebUtility.HtmlDecode(Regex.Replace(post.Post_Title, @"<[^>]*>", String.Empty));
                PostDataItem pdi = new PostDataItem(post.Post_Categories.First().Category_Id + "-Item-" + post.ID,
                                title,
                                post.Post_Image_Full_Url,
                                content,
                                group,
                                post.Post_Video_Url,
                                1);
                //group.Items.Add(pdi);

                if (!items.Contains(pdi))
                    items.Add(pdi);                
            }
            if (items == null)
                items = new List<PostDataItem>();
                            
            return items;            
        }
Exemple #3
0
        private async void GetAllCategoriesAsync(bool reload)
        {
            #region Recents posts
            if (!reload)
            {
                List<Posts> recentPosts = await PostsDal.GetRecentPost();

                var groupRecentPost = new PostDataGroup("0",
                       "Derniers articles",
                       "Assets/DarkGray.png",
                       1);
                foreach (Posts post in recentPosts)
                {
                    string content = WebUtility.HtmlDecode(Regex.Replace(post.Post_Content, @"<[^>]*>", String.Empty));
                    string title = WebUtility.HtmlDecode(Regex.Replace(post.Post_Title, @"<[^>]*>", String.Empty));

                    groupRecentPost.Items.Add(new PostDataItem("Derniers articles" + "-Item-" + post.ID,
                        title,
                        post.Post_Image_Full_Url,
                        content,
                        groupRecentPost,
                        post.Post_Video_Url,
                        1));
                }
                this.AllGroups.Add(groupRecentPost);
            }
            #endregion

            #region All Categories and posts
            //List<Category> Categories = await CategoryDal.GetAllCategories();
            List<Task<List<Posts>>> tasks = new List<Task<List<Posts>>>();
            List<Category> Categories = await CategoryDal.GetMainCategories();

            foreach (Category category in Categories)
            {
                var groupTest = GetGroup(category.Category_Id.ToString());
                if (groupTest == null)
                {
                    var group = new PostDataGroup(category.Category_Id.ToString(),
                        category.Category_Title,
                        "Assets/DarkGray.png",
                        1);
                    List<Posts> posts = await PostsDal.GetPostsByCategory(category.Category_Id.ToString());
                    tasks.Add(PostsDal.GetPostsByCategory(category.Category_Id.ToString()));
                    
                    

                    foreach (Posts post in posts)
                    {
                        string content = WebUtility.HtmlDecode(Regex.Replace(post.Post_Content, @"<[^>]*>", String.Empty));
                        //string contentNext = WebUtility.HtmlDecode(Regex.Replace(post.Post_Content_Next, @"<[^>]*>", String.Empty));
                        string title = WebUtility.HtmlDecode(Regex.Replace(post.Post_Title, @"<[^>]*>", String.Empty));
                        group.Items.Add(new PostDataItem(category.Category_Id.ToString() + "-Item-" + post.ID,
                            title,
                            post.Post_Image_Full_Url,
                            content,
                            group,
                            post.Post_Video_Url,
                            1));
                    }
                    this.AllGroups.Add(group);
                }
            }     
            #endregion                   
        }