public GroupArchiveViewModel(Group group, int?year, int?month, int?day, ContentTypeFilter contentType)
        {
            Feed     = new _ContentFeedViewModel();
            Calendar = new _CalendarViewModel();

            if (group != null)
            {
                GroupId     = group.Id;
                GroupName   = group.Name;
                GroupUrl    = group.Url;
                ContentType = contentType;

                if (contentType.IsSomethingChecked())
                {
                    IEnumerable <Content> content1 = group.Content.OfType <Post>().Where(x => x.State == (byte)ContentState.Approved);
                    IEnumerable <Content> content2 = group.Content.OfType <Voting>().Where(x => x.State == (byte)ContentState.Approved);
                    IEnumerable <Content> content  = content1.Union(content2);
                    IEnumerable <Content> feed     = null;

                    if (contentType.Posts)
                    {
                        IEnumerable <Post> posts = content.OfType <Post>();

                        if (feed == null)
                        {
                            feed = posts;
                        }
                        else
                        {
                            feed = feed.Union(posts);
                        }
                    }
                    if (contentType.Polls)
                    {
                        IEnumerable <Poll> polls = content.OfType <Poll>();

                        if (feed == null)
                        {
                            feed = polls;
                        }
                        else
                        {
                            feed = feed.Union(polls);
                        }
                    }
                    if (contentType.Petitions)
                    {
                        IEnumerable <Petition> petitions = content.OfType <Petition>();

                        if (feed == null)
                        {
                            feed = petitions;
                        }
                        else
                        {
                            feed = feed.Union(petitions);
                        }
                    }
                    if (contentType.Elections)
                    {
                        IEnumerable <Election> elections = content.OfType <Election>();

                        if (feed == null)
                        {
                            feed = elections;
                        }
                        else
                        {
                            feed = feed.Union(elections);
                        }
                    }

                    if (year.HasValue)
                    {
                        feed = feed.Where(x => x.PublishDate.Value.Year == year.Value);
                    }
                    if (month.HasValue)
                    {
                        feed = feed.Where(x => x.PublishDate.Value.Month == month.Value);
                    }
                    if (day.HasValue)
                    {
                        feed = feed.Where(x => x.PublishDate.Value.Day == day.Value);
                    }

                    Feed     = new _ContentFeedViewModel(feed.OrderByDescending(x => x.PublishDate));
                    Calendar = new _CalendarViewModel(group, year, month, day);
                }
            }
        }
 public GroupArchiveViewModel()
 {
     Feed     = new _ContentFeedViewModel();
     Calendar = new _CalendarViewModel();
 }
Esempio n. 3
0
        public UserArchiveViewModel(User user, int?year, int?month, int?day, ContentTypeFilter contentType, Personality personality)
        {
            Feed     = new _ContentFeedViewModel();
            Calendar = new _CalendarViewModel();

            if (user != null)
            {
                FullName    = user.FullName;
                UserId      = user.Id;
                ContentType = contentType;
                Personality = personality;

                if (contentType.IsSomethingChecked() && personality.IsSomethingChecked())
                {
                    IEnumerable <Content> content = user.Contents.Where(x => x.State == (byte)ContentState.Approved);
                    IEnumerable <Content> feed    = null;

                    if (contentType.Posts)
                    {
                        IEnumerable <Post> posts = null;

                        if (personality.User && personality.Group)
                        {
                            posts = content.OfType <Post>();
                        }
                        else if (personality.User)
                        {
                            posts = content.OfType <Post>().Where(x => !x.GroupId.HasValue);
                        }
                        else if (personality.Group)
                        {
                            posts = content.OfType <Post>().Where(x => x.GroupId.HasValue);
                        }

                        if (feed == null)
                        {
                            feed = posts;
                        }
                        else
                        {
                            feed = feed.Union(posts);
                        }
                    }
                    if (contentType.Petitions)
                    {
                        IEnumerable <Petition> petitions = null;

                        if (personality.User && personality.Group)
                        {
                            petitions = content.OfType <Petition>();
                        }
                        else if (personality.User)
                        {
                            petitions = content.OfType <Petition>().Where(x => x.Group == null);
                        }
                        else if (personality.Group)
                        {
                            petitions = content.OfType <Petition>().Where(x => x.Group != null);
                        }

                        if (feed == null)
                        {
                            feed = petitions;
                        }
                        else
                        {
                            feed = feed.Union(petitions);
                        }
                    }

                    if (year.HasValue)
                    {
                        feed = feed.Where(x => x.PublishDate.Value.Year == year.Value);
                    }
                    if (month.HasValue)
                    {
                        feed = feed.Where(x => x.PublishDate.Value.Month == month.Value);
                    }
                    if (day.HasValue)
                    {
                        feed = feed.Where(x => x.PublishDate.Value.Day == day.Value);
                    }

                    Feed     = new _ContentFeedViewModel(feed.OrderByDescending(x => x.PublishDate));
                    Calendar = new _CalendarViewModel(user, year, month, day);
                }
            }
        }
Esempio n. 4
0
        public UserArchiveViewModel(User user, int? year, int? month, int? day, ContentTypeFilter contentType, Personality personality)
        {
            Feed = new _ContentFeedViewModel();
            Calendar = new _CalendarViewModel();

            if (user != null)
            {
                FullName = user.FullName;
                UserId = user.Id;
                ContentType = contentType;
                Personality = personality;

                if (contentType.IsSomethingChecked() && personality.IsSomethingChecked())
                {
                    IEnumerable<Content> content = user.Contents.Where(x => x.State == (byte)ContentState.Approved);
                    IEnumerable<Content> feed = null;

                    if (contentType.Posts)
                    {
                        IEnumerable<Post> posts = null;

                        if (personality.User && personality.Group)
                            posts = content.OfType<Post>();
                        else if (personality.User)
                            posts = content.OfType<Post>().Where(x => !x.GroupId.HasValue);
                        else if (personality.Group)
                            posts = content.OfType<Post>().Where(x => x.GroupId.HasValue);

                        if (feed == null)
                            feed = posts;
                        else
                            feed = feed.Union(posts);
                    }
                    if (contentType.Petitions)
                    {
                        IEnumerable<Petition> petitions = null;

                        if (personality.User && personality.Group)
                            petitions = content.OfType<Petition>();
                        else if (personality.User)
                            petitions = content.OfType<Petition>().Where(x => x.Group == null);
                        else if (personality.Group)
                            petitions = content.OfType<Petition>().Where(x => x.Group != null);

                        if (feed == null)
                            feed = petitions;
                        else
                            feed = feed.Union(petitions);
                    }

                    if (year.HasValue)
                        feed = feed.Where(x => x.PublishDate.Value.Year == year.Value);
                    if (month.HasValue)
                        feed = feed.Where(x => x.PublishDate.Value.Month == month.Value);
                    if (day.HasValue)
                        feed = feed.Where(x => x.PublishDate.Value.Day == day.Value);

                    Feed = new _ContentFeedViewModel(feed.OrderByDescending(x => x.PublishDate));
                    Calendar = new _CalendarViewModel(user, year, month, day);
                }
            }
        }
Esempio n. 5
0
 public UserArchiveViewModel()
 {
     Feed = new _ContentFeedViewModel();
     Calendar = new _CalendarViewModel();
 }
        public GroupArchiveViewModel(Group group, int? year, int? month, int? day, ContentTypeFilter contentType)
        {
            Feed = new _ContentFeedViewModel();
            Calendar = new _CalendarViewModel();

            if (group != null)
            {
                GroupId = group.Id;
                GroupName = group.Name;
                GroupUrl = group.Url;
                ContentType = contentType;

                if (contentType.IsSomethingChecked())
                {
                    IEnumerable<Content> content1 = group.Content.OfType<Post>().Where(x => x.State == (byte)ContentState.Approved);
                    IEnumerable<Content> content2 = group.Content.OfType<Voting>().Where(x => x.State == (byte)ContentState.Approved);
                    IEnumerable<Content> content = content1.Union(content2);
                    IEnumerable<Content> feed = null;

                    if (contentType.Posts)
                    {
                        IEnumerable<Post> posts = content.OfType<Post>();

                        if (feed == null)
                            feed = posts;
                        else
                            feed = feed.Union(posts);
                    }
                    if (contentType.Polls)
                    {
                        IEnumerable<Poll> polls = content.OfType<Poll>();

                        if (feed == null)
                            feed = polls;
                        else
                            feed = feed.Union(polls);
                    }
                    if (contentType.Petitions)
                    {
                        IEnumerable<Petition> petitions = content.OfType<Petition>();

                        if (feed == null)
                            feed = petitions;
                        else
                            feed = feed.Union(petitions);
                    }
                    if (contentType.Elections)
                    {
                        IEnumerable<Election> elections = content.OfType<Election>();

                        if (feed == null)
                            feed = elections;
                        else
                            feed = feed.Union(elections);
                    }

                    if (year.HasValue)
                        feed = feed.Where(x => x.PublishDate.Value.Year == year.Value);
                    if (month.HasValue)
                        feed = feed.Where(x => x.PublishDate.Value.Month == month.Value);
                    if (day.HasValue)
                        feed = feed.Where(x => x.PublishDate.Value.Day == day.Value);

                    Feed = new _ContentFeedViewModel(feed.OrderByDescending(x => x.PublishDate));
                    Calendar = new _CalendarViewModel(group, year, month, day);
                }
            }
        }