public override ICachedViewModel Initialize() { var groups = DataService.PerThread.GroupSet.OrderByDescending(x => 5 * x.GroupMembers.Count(gm => gm.State == (byte)GroupMemberState.Approved || gm.State == (byte)GroupMemberState.Moderator) + 2 * x.Content.OfType<Post>().Count(p => p.State == (byte)ContentState.Approved)).Where(x => x.State != (byte)GroupState.Blank && x.State != (byte)GroupState.Archive).Take(20).ToList(); var users = DataService.PerThread.BaseUserSet.OfType<User>().OrderByDescending(x => 5 * x.Subscribers.Count + 2 * x.Contents.OfType<Post>().Count(p => p.State == (byte)ContentState.Approved)).Take(20).ToList(); /*var yesterday = DateTime.Now.AddDays(-2); var recent = DataService.PerThread.ContentSet.OfType<Post>() .Where(x => x.PublishDate.HasValue && x.State == (byte)ContentState.Approved) .Where(x => x.PublishDate.Value <= DateTime.Now && x.PublishDate.Value > yesterday) .Where(x => !x.GroupId.HasValue || (x.Group.State != (byte)GroupState.Blank || x.Group.State != (byte)GroupState.Archive)) .OrderByDescending(x => 2 * x.Comments.Count + 5 * (x.Likes.Count(a => a.Value) - x.Likes.Count(a => !a.Value)) + x.Likes.Count) .Take(10).ToList().OfType<Content>().ToList();*/ var rootGroup = DataService.PerThread.GroupSet.SingleOrDefault(x => x.Id == ConstHelper.RootGroupId); IEnumerable<Content> recent = new List<Content>(); if (rootGroup != null) { List<Content> content = new List<Content>(); var polls = rootGroup.Content.OfType<Poll>().Where(x => x.State == (byte)ContentState.Approved); var surveys = rootGroup.Content.OfType<Survey>().Where(x => x.State == (byte)ContentState.Approved); content.AddRange(polls); content.AddRange(surveys); recent = content.OrderByDescending(x => x.PublishDate); } Recent = new _ContentFeedViewModel(recent); Popular = new Home_PopularViewModel(groups, users); return this; }
public GroupSearchViewModel(string groupUrl, string tag) { var curGroup = GroupService.GetGroupByLabelOrId(groupUrl); GroupId = curGroup.Id; GroupUrl = curGroup.Url; GroupName = curGroup.Name; IEnumerable<Content> feed = null; Guid tagId; if (Guid.TryParse(tag, out tagId)) { var t = DataService.PerThread.TagSet.SingleOrDefault(x => x.Id == tagId); if (t == null) throw new BusinessLogicException("Указан неверный идентификатор темы"); Tag = t.Title; feed = DataService.PerThread.ContentSet.Where(x => x.Tags.Any(y => y.Id == tagId) && x.State == (byte)ContentState.Approved).OrderByDescending(x=>x.PublishDate); } else if(!string.IsNullOrWhiteSpace(tag)) { Tag = tag; tag = tag.ToLower(); feed = from content in DataService.PerThread.ContentSet.Where(x => x.GroupId == curGroup.Id && x.State == (byte)ContentState.Approved) where content.Tags.Any(x => x.LowerTitle == tag) orderby content.PublishDate descending select content; } Feed = new _ContentFeedViewModel(feed); }
public override ICachedViewModel Initialize() { var groups = DataService.PerThread.GroupSet.OrderByDescending(x => 5 * x.GroupMembers.Count(gm => gm.State == (byte)GroupMemberState.Approved || gm.State == (byte)GroupMemberState.Moderator) + 2 * x.Content.OfType <Post>().Count(p => p.State == (byte)ContentState.Approved)).Where(x => x.State != (byte)GroupState.Blank && x.State != (byte)GroupState.Archive).Take(20).ToList(); var users = DataService.PerThread.BaseUserSet.OfType <User>().OrderByDescending(x => 5 * x.Subscribers.Count + 2 * x.Contents.OfType <Post>().Count(p => p.State == (byte)ContentState.Approved)).Take(20).ToList(); /*var yesterday = DateTime.Now.AddDays(-2); * var recent = DataService.PerThread.ContentSet.OfType<Post>() * .Where(x => x.PublishDate.HasValue && x.State == (byte)ContentState.Approved) * .Where(x => x.PublishDate.Value <= DateTime.Now && x.PublishDate.Value > yesterday) * .Where(x => !x.GroupId.HasValue || (x.Group.State != (byte)GroupState.Blank || x.Group.State != (byte)GroupState.Archive)) * .OrderByDescending(x => 2 * x.Comments.Count + 5 * (x.Likes.Count(a => a.Value) - x.Likes.Count(a => !a.Value)) + x.Likes.Count) * .Take(10).ToList().OfType<Content>().ToList();*/ var rootGroup = DataService.PerThread.GroupSet.SingleOrDefault(x => x.Id == ConstHelper.RootGroupId); IEnumerable <Content> recent = new List <Content>(); if (rootGroup != null) { List <Content> content = new List <Content>(); var polls = rootGroup.Content.OfType <Poll>().Where(x => x.State == (byte)ContentState.Approved); var surveys = rootGroup.Content.OfType <Survey>().Where(x => x.State == (byte)ContentState.Approved); content.AddRange(polls); content.AddRange(surveys); recent = content.OrderByDescending(x => x.PublishDate); } Recent = new _ContentFeedViewModel(recent); Popular = new Home_PopularViewModel(groups, users); return(this); }
public UserBlogViewModel(User user, Guid? currentUid = null) { if (user == null) return; UserId = user.Id; UserFullName = user.FullName; if (currentUid.HasValue && user.BlackList.Count(x => x.Id == currentUid.Value) == 0) IsPMAllow = true; var feed = user.Contents.Where(x => x.State == (byte)ContentState.Approved && x.PublishDate.HasValue).OrderByDescending(x => x.PublishDate); Feed = new _ContentFeedViewModel(feed, user.Id); }
public User_SubscriptionViewModel(User user, DateTime startDate, DateTime endDate) { if (user != null) { var groupContent = (from _group in user.SubscriptionGroups join content in DataService.PerThread.ContentSet on _group.Id equals content.GroupId where content.State == (byte)ContentState.Approved && startDate <= content.PublishDate && content.PublishDate <= endDate && !user.BlackList.Contains(content.Author) select content).ToList(); var userContent = (from _user in user.SubscriptionUsers join content in DataService.PerThread.ContentSet on _user.Id equals content.AuthorId where content.State == (byte)ContentState.Approved && startDate <= content.PublishDate && content.PublishDate <= endDate select content).ToList(); var feed = groupContent.Union(userContent).Distinct().Where(x => x.AuthorId != user.Id).OrderByDescending(c => c.PublishDate); LastContents = new _ContentFeedViewModel(feed, 10); } }
public UserBlogViewModel(User user, Guid?currentUid = null) { if (user == null) { return; } UserId = user.Id; UserFullName = user.FullName; if (currentUid.HasValue && user.BlackList.Count(x => x.Id == currentUid.Value) == 0) { IsPMAllow = true; } var feed = user.Contents.Where(x => x.State == (byte)ContentState.Approved && x.PublishDate.HasValue).OrderByDescending(x => x.PublishDate); Feed = new _ContentFeedViewModel(feed, user.Id); }
public UserVotingsViewModel(User user) { VotingsFeed = new _ContentFeedViewModel(); PreviosPolls = new _PollStatusViewModel(); if (user != null) { UserName = user.FullName; UserId = user.Id; var newVotings = (from _group in user.GroupMembers.Select(x => x.Group) join content in DataService.PerThread.ContentSet.OfType <Poll>() on _group.Id equals content.GroupId where content.State == (byte)ContentState.Approved && !content.IsFinished select content).OfType <Content>(); var finishedVotings = (from _group in user.GroupMembers.Select(x => x.Group) join content in DataService.PerThread.ContentSet.OfType <Poll>() on _group.Id equals content.GroupId where content.State == (byte)ContentState.Approved && content.IsFinished select content).Take(10).ToList(); VotingsFeed = new _ContentFeedViewModel(newVotings, UserId); PreviosPolls = new _PollStatusViewModel(finishedVotings, user.Id); } }
public UserVotingsViewModel(User user) { VotingsFeed = new _ContentFeedViewModel(); PreviosPolls = new _PollStatusViewModel(); if (user != null) { UserName = user.FullName; UserId = user.Id; var newVotings = (from _group in user.GroupMembers.Select(x => x.Group) join content in DataService.PerThread.ContentSet.OfType<Poll>() on _group.Id equals content.GroupId where content.State == (byte)ContentState.Approved && !content.IsFinished select content).OfType<Content>(); var finishedVotings = (from _group in user.GroupMembers.Select(x => x.Group) join content in DataService.PerThread.ContentSet.OfType<Poll>() on _group.Id equals content.GroupId where content.State == (byte)ContentState.Approved && content.IsFinished select content).Take(10).ToList(); VotingsFeed = new _ContentFeedViewModel(newVotings, UserId); PreviosPolls = new _PollStatusViewModel(finishedVotings, user.Id); } }
public GroupSearchViewModel(string groupUrl, string tag) { var curGroup = GroupService.GetGroupByLabelOrId(groupUrl); GroupId = curGroup.Id; GroupUrl = curGroup.Url; GroupName = curGroup.Name; IEnumerable <Content> feed = null; Guid tagId; if (Guid.TryParse(tag, out tagId)) { var t = DataService.PerThread.TagSet.SingleOrDefault(x => x.Id == tagId); if (t == null) { throw new BusinessLogicException("Указан неверный идентификатор темы"); } Tag = t.Title; feed = DataService.PerThread.ContentSet.Where(x => x.Tags.Any(y => y.Id == tagId) && x.State == (byte)ContentState.Approved).OrderByDescending(x => x.PublishDate); } else if (!string.IsNullOrWhiteSpace(tag)) { Tag = tag; tag = tag.ToLower(); feed = from content in DataService.PerThread.ContentSet.Where(x => x.GroupId == curGroup.Id && x.State == (byte)ContentState.Approved) where content.Tags.Any(x => x.LowerTitle == tag) orderby content.PublishDate descending select content; } Feed = new _ContentFeedViewModel(feed); }
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 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); } } }
public GroupArchiveViewModel() { Feed = new _ContentFeedViewModel(); Calendar = new _CalendarViewModel(); }
public UserArchiveViewModel() { Feed = new _ContentFeedViewModel(); Calendar = new _CalendarViewModel(); }
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); } } }
public UserVotingsViewModel() { VotingsFeed = new _ContentFeedViewModel(); PreviosPolls = new _PollStatusViewModel(); }
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 override ICachedViewModel Initialize() { var group = GroupService.GetGroupByLabelOrId(_groupId); var membersCount = DataService.PerThread.GroupMemberSet.Count(gm => gm.GroupId == group.Id && (gm.State == (byte)GroupMemberState.Approved || gm.State == (byte)GroupMemberState.Moderator)); var moderatorsCount = DataService.PerThread.GroupMemberSet.Count(gm => gm.GroupId == group.Id && gm.State == (byte)GroupMemberState.Moderator); State = (GroupState)group.State; GroupId = group.Id; MembersCount = membersCount; Name = group.Name; Summary = TextHelper.CleanTags(group.Summary); if (Summary.Length > 500) { Summary = Summary.Substring(0, 500) + "…"; } Url = group.Url; GroupTagsCount = group.Tags.Count; RequiredModers = group.ModeratorsCount - moderatorsCount; IsExpertable = group.Tags.Count != 0; IsEditEnabled = group.Content.OfType <Election>().Count(x => !x.IsFinished) == 0; IsInvisible = group.PrivacyEnum.HasFlag(GroupPrivacy.Invisible); IsCreateElectionEnabled = GroupService.CanElectionsBeStarted(group); Topics = group.Tags.Where(x => x.TopicState == (byte)TopicState.GroupTopic).OrderByDescending(x => x.Weight).Take(5).ToList() .Select(x => new GroupIndex_TopicViewModel(x)).ToList(); IQueryable <Content> feedQueue; if (_userId.HasValue && _userId.Value != Guid.Empty) { var uig = GroupService.UserInGroup(_userId.Value, GroupId); if (uig != null) { MemberId = uig.Id; feedQueue = DataService.PerThread.ContentSet.Where(x => x.GroupId.HasValue && x.GroupId.Value == _groupId && (x.State == (byte)ContentState.Approved || (x.State == (byte)ContentState.Premoderated && (x.AuthorId.HasValue && x.AuthorId.Value == _userId.Value || uig.State == (byte)GroupMemberState.Moderator)))); } else { feedQueue = DataService.PerThread.ContentSet.Where(x => x.GroupId.HasValue && x.GroupId.Value == _groupId && x.State == (byte)ContentState.Approved); } } else { feedQueue = DataService.PerThread.ContentSet.Where(x => x.GroupId.HasValue && x.GroupId.Value == _groupId && x.State == (byte)ContentState.Approved); } if (ByDate.HasValue && ByDate.Value) { feedQueue = feedQueue.OrderByDescending(x => x.PublishDate ?? DateTime.Now); } else { /*feedQueue = (from content in feedQueue.Where(x => x.PublishDate.HasValue) * join comment in DataService.PerThread.CommentSet on content.Id equals comment.ContentId * join like in DataService.PerThread.LikeSet on content.Id equals like.ContentId * let commentsCount = content.Comments.Count * let likesCount = content.Likes.Count * let plusesCount = content.Likes.Count(x => x.Value) * let minusesCount = content.Likes.Count(x => !x.Value) * //orderby (Math.Pow(plusesCount * likesCount, 0.5) + commentsCount / 10) / * // Math.Pow(EntityFunctions.DiffDays(content.PublishDate.Value, DateTime.Now).Value + 0.01, 0.5) / * // Math.Pow(minusesCount + 1, 0.5) descending * orderby (Math.Pow(plusesCount * likesCount, 0.5) + commentsCount / 10 + 7) / * Math.Pow((EntityFunctions.DiffDays(content.PublishDate.Value, DateTime.Now).Value + 0.01) * (minusesCount + 1), 0.5) * descending * select content);*/ feedQueue = feedQueue.OrderByDescending(x => (Math.Pow(x.Likes.Count(y => y.Value) * x.Likes.Count, 0.5) + x.Comments.Count / 10 + 7) / Math.Pow((EntityFunctions.DiffDays(x.PublishDate.Value, DateTime.Now).Value + 0.01) * (x.Likes.Count(y => !y.Value) + 1), 0.5)); } if (TopicId.HasValue) { feedQueue = feedQueue.Where(x => x.Tags.Count(y => y.Id == TopicId.Value) != 0); } Feed = new _ContentFeedViewModel(feedQueue, Url); Moders = new Group_ModersViewModel(group); return(this); }
public HomeIndexViewModel() { Recent = new _ContentFeedViewModel(); Popular = new Home_PopularViewModel(); }
public override ICachedViewModel Initialize() { var group = GroupService.GetGroupByLabelOrId(_groupId); var membersCount = DataService.PerThread.GroupMemberSet.Count(gm => gm.GroupId == group.Id && (gm.State == (byte)GroupMemberState.Approved || gm.State == (byte)GroupMemberState.Moderator)); var moderatorsCount = DataService.PerThread.GroupMemberSet.Count(gm => gm.GroupId == group.Id && gm.State == (byte)GroupMemberState.Moderator); State = (GroupState)group.State; GroupId = group.Id; MembersCount = membersCount; Name = group.Name; Summary = TextHelper.CleanTags(group.Summary); if (Summary.Length > 500) Summary = Summary.Substring(0, 500) + "…"; Url = group.Url; GroupTagsCount = group.Tags.Count; RequiredModers = group.ModeratorsCount - moderatorsCount; IsExpertable = group.Tags.Count != 0; IsEditEnabled = group.Content.OfType<Election>().Count(x => !x.IsFinished) == 0; IsInvisible = group.PrivacyEnum.HasFlag(GroupPrivacy.Invisible); IsCreateElectionEnabled = GroupService.CanElectionsBeStarted(group); Topics = group.Tags.Where(x => x.TopicState == (byte) TopicState.GroupTopic).OrderByDescending(x => x.Weight).Take(5).ToList() .Select(x => new GroupIndex_TopicViewModel(x)).ToList(); IQueryable<Content> feedQueue; if (_userId.HasValue && _userId.Value != Guid.Empty) { var uig = GroupService.UserInGroup(_userId.Value, GroupId); if (uig != null) { MemberId = uig.Id; feedQueue = DataService.PerThread.ContentSet.Where(x => x.GroupId.HasValue && x.GroupId.Value == _groupId && (x.State == (byte)ContentState.Approved || (x.State == (byte)ContentState.Premoderated && (x.AuthorId.HasValue && x.AuthorId.Value == _userId.Value || uig.State == (byte)GroupMemberState.Moderator)))); } else feedQueue = DataService.PerThread.ContentSet.Where(x => x.GroupId.HasValue && x.GroupId.Value == _groupId && x.State == (byte)ContentState.Approved); } else feedQueue = DataService.PerThread.ContentSet.Where(x => x.GroupId.HasValue && x.GroupId.Value == _groupId && x.State == (byte)ContentState.Approved); if (ByDate.HasValue && ByDate.Value) feedQueue = feedQueue.OrderByDescending(x => x.PublishDate ?? DateTime.Now); else { /*feedQueue = (from content in feedQueue.Where(x => x.PublishDate.HasValue) join comment in DataService.PerThread.CommentSet on content.Id equals comment.ContentId join like in DataService.PerThread.LikeSet on content.Id equals like.ContentId let commentsCount = content.Comments.Count let likesCount = content.Likes.Count let plusesCount = content.Likes.Count(x => x.Value) let minusesCount = content.Likes.Count(x => !x.Value) //orderby (Math.Pow(plusesCount * likesCount, 0.5) + commentsCount / 10) / // Math.Pow(EntityFunctions.DiffDays(content.PublishDate.Value, DateTime.Now).Value + 0.01, 0.5) / // Math.Pow(minusesCount + 1, 0.5) descending orderby (Math.Pow(plusesCount * likesCount, 0.5) + commentsCount / 10 + 7) / Math.Pow((EntityFunctions.DiffDays(content.PublishDate.Value, DateTime.Now).Value + 0.01) * (minusesCount + 1), 0.5) descending select content);*/ feedQueue = feedQueue.OrderByDescending(x => (Math.Pow(x.Likes.Count(y => y.Value) * x.Likes.Count, 0.5) + x.Comments.Count / 10 + 7) / Math.Pow((EntityFunctions.DiffDays(x.PublishDate.Value, DateTime.Now).Value + 0.01) * (x.Likes.Count(y => !y.Value) + 1), 0.5)); } if (TopicId.HasValue) feedQueue = feedQueue.Where(x => x.Tags.Count(y => y.Id == TopicId.Value) != 0); Feed = new _ContentFeedViewModel(feedQueue, Url); Moders = new Group_ModersViewModel(group); return this; }