コード例 #1
0
ファイル: ForGroupPanel.cs プロジェクト: Shkorodenok/Articles
 public ForGroupPanel(GroupViewItem view)
 {
     Articles = new List<ForPanel>();
     this.Name = view.Name;
     this.IsExpanded = view.IsExpanded;
     this.ArticleCount = view.ArticlesCount;
     Articles = view.Articles.Select(c => new ForPanel { Id = c.ArticleId, Name = c.ArticleName, Rate = c.Rate}).OrderBy(c=>c.Name).ToList();
 }
コード例 #2
0
        public ForGroupPanel(GroupViewItem view)
        {
            Articles          = new List <ForPanel>();
            this.Name         = view.Name;
            this.IsExpanded   = view.IsExpanded;
            this.ArticleCount = view.ArticlesCount;
            Func <IEnumerable <Tag>, string> define = (items) =>
            {
                return
                    ("[{0}]".Fmt(string.Join(",", items
                                             .OrderByDescending(c => c.Priority)
                                             .Select(c => string.Format("{0}{5}Name{5}:{5}{1}{5},{5}TagColor{5}:{5}{2}{5},{5}Priority{5}:{5}{3}{5}{4}", "{", c.Name, c.TagColor, c.Priority, "}", "'")))));
            };

            Articles = view.Articles.Select(c => new ForPanel {
                Id = c.ArticleId, Name = c.ArticleName, Rate = c.Rate, CountOfImages = c.Images.Count, CreationDate = c.CreationDate, Tags = define(c.Tags)
            }).OrderBy(c => c.Name).ToList();
        }
コード例 #3
0
ファイル: GroupView.cs プロジェクト: fafnir901/fwd
        public GroupView(IEnumerable <ArticleGroup> groups, IEnumerable <Article> articles)
        {
            GroupViewItems = new List <GroupViewItem>();

            var lst = new List <Article>();

            foreach (var articleGroup in groups)
            {
                var currentArticles = articles.Where(c => articleGroup.Groups.Contains(c.ArticleName)).ToList();
                if (currentArticles.Any())
                {
                    GroupViewItems.Add(new GroupViewItem(articleGroup, currentArticles));
                    lst.AddRange(currentArticles);
                }
            }

            var withOutcurrentArticles = articles.Except(lst);

            if (withOutcurrentArticles.Any())
            {
                var res = GroupViewItems.FirstOrDefault(c => c.Name == "Без группы");
                if (res == null)
                {
                    res = new GroupViewItem(groups.First(c => c.GroupName == "Без группы"), new List <Article>());
                    GroupViewItems.Add(res);
                }
                res.Articles.AddRange(withOutcurrentArticles);
                res.ArticlesCount = res.Articles.Count;
            }

            var withOutArticles = groups.Where(c => !GroupViewItems.Select(x => x.Name).Contains(c.GroupName));

            foreach (var withOutArticle in withOutArticles)
            {
                GroupViewItems.Add(new GroupViewItem(withOutArticle, null));
            }

            GroupViewItems = GroupViewItems.OrderBy(c => c.Name).ToList();
        }
コード例 #4
0
ファイル: GroupView.cs プロジェクト: Shkorodenok/Articles
        public GroupView(IEnumerable<ArticleGroup> groups, IEnumerable<Article> articles)
        {
            GroupViewItems = new List<GroupViewItem>();

            var lst = new List<Article>();
            foreach (var articleGroup in groups)
            {
                var currentArticles = articles.Where(c => articleGroup.Groups.Contains(c.ArticleName)).ToList();
                if (currentArticles.Any())
                {
                    GroupViewItems.Add(new GroupViewItem(articleGroup, currentArticles));
                    lst.AddRange(currentArticles);
                }
            }

            var withOutcurrentArticles = articles.Except(lst);
            if (withOutcurrentArticles.Any())
            {
                var res = GroupViewItems.FirstOrDefault(c => c.Name == "Без группы");
                if (res == null)
                {
                    res = new GroupViewItem(groups.First(c => c.GroupName == "Без группы"), new List<Article>());
                    GroupViewItems.Add(res);
                }
                res.Articles.AddRange(withOutcurrentArticles);
                res.ArticlesCount = res.Articles.Count;
            }

            var withOutArticles = groups.Where(c => !GroupViewItems.Select(x => x.Name).Contains(c.GroupName));
            foreach (var withOutArticle in withOutArticles)
            {
                GroupViewItems.Add(new GroupViewItem(withOutArticle, null));
            }

            GroupViewItems = GroupViewItems.OrderBy(c => c.Name).ToList();
        }