public Group_ModersViewModel(Group group = null)
        {
            ModeratorList = new List<Group_Moders_ItemViewModel>();
            if (group != null)
            {
                var moderators = DataService.PerThread.GroupMemberSet.Where(x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.Moderator).ToList();

                foreach (var moderator in moderators)
                    ModeratorList.Add(new Group_Moders_ItemViewModel(moderator.User));

                EmptySlots = group.ModeratorsCount - ModeratorList.Count;
                EmptySlots = EmptySlots < 0 ? 0 : EmptySlots;

                FreeSlots = 3 - ModeratorList.Count;
                FreeSlots = FreeSlots < 0 ? 0 : FreeSlots;

                CanBeModerator = false;
                if (FreeSlots > 0 && UserContext.Current != null)
                {
                    var gm = GroupService.UserInGroup(UserContext.Current.Id, group);
                    if (gm != null)
                    {
                        MemberId = gm.Id;
                        if (group.State == (byte)GroupState.Archive)
                            CanBeModerator = true;
                    }
                }

            }
        }
示例#2
0
 public _BadgesViewModel(Group group)
 {
     if (group != null)
         Badges = group.Badges.Where(x => x.IsAcquired).Select(x => new BadgeViewModel(x)).ToList();
     else
         Badges = new List<BadgeViewModel>();
 }
示例#3
0
        public UserVoters_GroupViewModel(Group group, Expert expert, Guid userId)
        {
            if (group == null)
                return;

            Name = group.Name;
            Url = group.Url;
            Logo = ImageService.GetImageUrl<Group>(group.Logo);
            ExpertId = expert.Id.ToString();

            var expertGroupMember = GroupService.UserInGroup(userId, group);
            GroupMember userGroupMember = null;
            if(UserContext.Current != null)
                userGroupMember = GroupService.UserInGroup(UserContext.Current.Id, group);
            VotersCount = DataService.PerThread.ExpertVoteSet.Where(x => x.ExpertId == expert.Id).GroupBy(x => x.GroupMemberId).Count();
            ExpertTags = expertGroupMember.Expert.Tags.Select(x => new TagViewModel(x)).ToList();

            foreach (var tag in ExpertTags)
            {
                tag.IsChecked = false;

                if (userGroupMember!= null && userGroupMember.ExpertVotes.Count(x => x.TagId == tag.Id) > 0)
                    tag.IsChecked = true;
            }
        }
示例#4
0
        public AlbumsViewModel(User user, Group group)
        {
            GroupAlbums = new List<AlbumViewModel>();
            UserAlbums = new List<AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum = new AlbumCreateEditViewModel();

            if (group != null)
            {
                GroupId = group.Id;
                GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateGroupAlbum = new AlbumCreateEditViewModel(group);
            }

            if (user != null)
            {
                UserId = user.Id;
                UserAlbums = user.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateUserAlbum = new AlbumCreateEditViewModel(user);
            }

            Albums = GroupAlbums.Union(UserAlbums).ToList();
        }
示例#5
0
        public _CalendarViewModel(Group group, int? year, int? month, int? day)
        {
            Type = CalednarType.Archive;

            Day = day;
            Month = month;
            Year = year;

            ContentDates = new List<DateTime>();

            if (group != null)
            {
                Id = group.Url;

                foreach (Post post in group.Content.OfType<Post>().Where(x => x.State == (byte)ContentState.Approved).ToList())
                    if (post.PublishDate.HasValue)
                        if (!ContentDates.Contains(post.PublishDate.Value))
                            ContentDates.Add(post.PublishDate.Value.Date);

                foreach (Voting voting in group.Content.OfType<Voting>().Where(x => x.State == (byte)ContentState.Approved).ToList())
                    if (voting.PublishDate.HasValue)
                        if (!ContentDates.Contains(voting.PublishDate.Value))
                            ContentDates.Add(voting.PublishDate.Value.Date);
            }
        }
 public GroupAddFgFormViewModel(Group group)
 {
     if (group != null)
     {
         GroupId = group.Id;
         GroupUrl = group.Url;
     }
 }
 public GroupAddTagViewModel(Group group)
 {
     if (group != null)
     {
         GroupName = group.Name;
         GroupUrl = group.Url;
         GroupId = group.Id;
     }
 }
        public UserEditSubscription_GroupViewModel(Group group, User user)
        {
            Logo = ImageService.GetImageUrl<Group>(group.Logo);
            Name = group.Name;
            Url = group.Url;

            var uig = GroupService.UserInGroup(user.Id, group.Id);
            UserIsMember = uig != null;
        }
        public void SubscribeToGroup(Group group, User subscriber, bool saveChanges)
        {
            if (!subscriber.SubscriptionGroups.Contains(group))
            {
                subscriber.SubscriptionGroups.Add(group);

                if (saveChanges)
                    DataService.PerThread.SaveChanges();
            }
        }
 public GroupAddPostViewModel(Group group = null)
 {
     if (group != null)
     {
         GroupId = group.Id;
         GroupUrl = group.Url;
         GroupName = group.Name;
         IsContentModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);
     }
 }
 public Group_RecommendedGroups_GroupViewModel(Group group)
 {
     if (group != null)
     {
         Id = group.Id;
         Logo = ImageService.GetImageUrl<Group>(group.Logo);
         Name = group.Name;
         Url = group.Url;
     }
 }
 public Home_Popular_GroupViewModel(Group group)
 {
     if (group != null)
     {
         Id = group.Id;
         Url = group.Url;
         Name = group.Name;
         MembersCount = DataService.PerThread.GroupMemberSet.Where(x => x.GroupId == group.Id && (x.State == (byte)GroupMemberState.Approved || x.State == (byte)GroupMemberState.Moderator)).Count();
         PostsCount = DataService.PerThread.ContentSet.OfType<Post>().Count(x => x.GroupId == group.Id && x.State == (byte)ContentState.Approved);
     }
 }
示例#13
0
 public GroupPrivacyViewModel(Group group)
 {
     GroupId = group.Id;
     GroupUrl = group.Url;
     GroupName = group.Name;
     var groupPrivacy = (GroupPrivacy)group.Privacy;
     IsMemberModeration = groupPrivacy.HasFlag(GroupPrivacy.MemberModeration);
     IsContentModeration = groupPrivacy.HasFlag(GroupPrivacy.ContentModeration);
     IsPrivateDiscussion = groupPrivacy.HasFlag(GroupPrivacy.PrivateDiscussion);
     IsInvisible = groupPrivacy.HasFlag(GroupPrivacy.Invisible);
 }
 public SearchTag_GroupViewModel(Group group)
 {
     if (group != null)
     {
         Link = UrlHelper.GetUrl<Group>(group.Url);
         Logo = ImageService.GetImageUrl<Group>(group.Logo);
         Name = group.Name;
         MembersCount = group.GroupMembers.Count(x => x.State == (byte) GroupMemberState.Approved || x.State == (byte) GroupMemberState.Moderator);
         CreationDate = group.CreationDate;
     }
 }
示例#15
0
        private void FixupGroup(Group previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.GroupAd, this))
            {
                previousValue.GroupAd = null;
            }

            if (Group != null)
            {
                Group.GroupAd = this;
            }
        }
示例#16
0
        public static IList<Tag> ConvertStringToTagList(string tags, Group group)
        {
            IList<Tag> tagList = new List<Tag>();

            var tagsArr = SplitTagsString(tags);
            foreach (var tag in tagsArr)
            {
                if (!string.IsNullOrWhiteSpace(tag))
                    tagList.Add(TagService.GetTag(tag.Trim(), group, true));
            }

            return tagList;
        }
        public GroupRequestsViewModel(Group group)
        {
            if (group != null)
            {
                GroupId = group.Id;
                GroupUrl = group.Url;
                GroupName = group.Name;
                GroupIsBlank = group.State == (byte)GroupState.Archive || group.State == (byte)GroupState.Blank;

                foreach (var member in group.GroupMembers.Where(x => x.State == (byte) GroupMemberState.NotApproved))
                    Requests.Add(new GroupRequestsViewModel_RequestViewModel(member));
            }
        }
        public GroupCreatePetitionViewModel(Group group)
        {
            CreatePetition = new _CreatePetitionViewModel();

            if (group != null)
            {
                GroupId = group.Id;
                GroupName = group.Name;
                GroupUrl = group.Url;
                IsContentModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);

                CreatePetition.GroupId = group.Id;
            }
        }
示例#19
0
        public static void SendToGroup(Group group, string text, MessageType type, GroupMessageRecipientType recipientType = GroupMessageRecipientType.Members, Guid? authorId = null, DateTime? date = null)
        {
            if (!date.HasValue)
                date = DateTime.Now;

            var messageInfo = new MessageStruct
            {
                AuthorId = authorId,
                Text = text,
                Type = (byte)type,
                Date = date.Value
            };

            Current.SendToGroup(group, messageInfo, recipientType);
        }
示例#20
0
 public GroupEditTagViewModel(Group group, Guid tagId)
 {
     if (group != null)
     {
         GroupName = group.Name;
         GroupUrl = group.Url;
         GroupId = group.Id;
         var tag = group.Tags.SingleOrDefault(x=>x.Id == tagId);
         if (tag == null)
             throw new BusinessLogicException("В данной группе нет тега с таким идентификатором");
         TagId = tagId;
         Title = tag.Title;
         Description = tag.Description;
     }
 }
        public GroupChildren_GroupViewModel(Group group)
        {
            if (group != null)
            {
                Id = group.Id;
                Logo = ImageService.GetImageUrl<Group>(group.Logo);
                Name = group.Name;
                Url = group.Url;
                MembersCount = group.GroupMembers.Count(gm => gm.State == (byte)GroupMemberState.Approved || gm.State == (byte)GroupMemberState.Moderator);

                Tags = new List<TagViewModel>();
                foreach (var tag in group.Tags)
                    Tags.Add(new TagViewModel(tag));
            }
        }
        public GroupChildrenViewModel(Group group)
        {
            FormedGroups = new List<GroupChildren_GroupViewModel>();
            BlankGroups = new List<GroupChildren_GroupViewModel>();

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

                foreach (var child in group.ChildGroups.Where(g => g.State != (byte)GroupState.Blank && g.State != (byte)GroupState.Archive).OrderByDescending(g => g.GroupMembers.Count))
                    FormedGroups.Add(new GroupChildren_GroupViewModel(child));

                foreach (var child in group.ChildGroups.Where(g => g.State == (byte)GroupState.Blank || g.State == (byte)GroupState.Archive).OrderByDescending(g => g.GroupMembers.Count))
                    BlankGroups.Add(new GroupChildren_GroupViewModel(child));
            }
        }
示例#23
0
        public AlbumsViewModel(Group group)
        {
            GroupAlbums = new List<AlbumViewModel>();
            UserAlbums = new List<AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum = new AlbumCreateEditViewModel();

            if (group != null)
            {
                GroupId = group.Id;
                GroupUrl = group.Url;
                GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateGroupAlbum = new AlbumCreateEditViewModel(group);
            }

            Albums = GroupAlbums;
        }
        public GroupEditExpertInfoViewModel(Group group, Guid? userId)
        {
            if (group != null)
            {
                GroupId = group.Id;
                GroupUrl = group.Url;
                GroupName = group.Name;

                if (userId.HasValue)
                {
                    var uig = GroupService.UserInGroup(userId.Value, group.Id);

                    if (uig != null && uig.Expert != null)
                    {
                        Info = uig.Expert.Info;
                    }
                }
            }
        }
        public GroupEditLogoViewModel(Group group)
        {
            GroupUrl = group.Url;
            GroupName = group.Name;

            LogoImageName = group.Logo;

            LogoUrl = ImageService.GetImageUrl<Group>(group.Logo);

            if (LogoUrl == ConstHelper.DefaultImageName)
                HasLogo = false;
            else
            {
                HasLogo = true;
                var size = ImageService.GetImageSize<Group>(group.Logo);

                ImageWidth = size.Width;
                ImageHeight = size.Height;
            }
        }
        public GroupCreateEditSurveyViewModel(Group group)
        {
            VariantsCount = 1;

            Options = new List<GroupSurveyOptionViewModel>();
            Options.Add(new GroupSurveyOptionViewModel());
            Options.Add(new GroupSurveyOptionViewModel());

            if (group != null)
            {
                GroupId = group.Id;
                GroupName = group.Name;
                GroupUrl = group.Url;
                IsContentModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);

                if (GroupId == new Guid(ConstHelper.KsGroupId))
                {
                    HasOpenProtocol = true;
                }
            }
        }
示例#27
0
        public GroupMembersViewModel(Group group, string query = null)
        {
            if (group != null)
            {
                GroupId = group.Id;
                GroupUrl = group.Url;
                GroupName = group.Name;
                GroupPrivacy = (GroupPrivacy)group.Privacy;
                MaxModers = group.ModeratorsCount;
                IsMemberModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.MemberModeration);
                IsBlank = group.State == (byte)GroupState.Blank;

                MembersTotalCount = DataService.PerThread.GroupMemberSet.Count(x => x.GroupId == group.Id && (x.State == (byte)GroupMemberState.Approved || x.State == (byte)GroupMemberState.Moderator));

                var groupMembers = group.GroupMembers;

                RequestsCount = groupMembers.Count(x => x.State == (byte)GroupMemberState.NotApproved);
                Moderators = new Group_ModersViewModel(group);
                NoPhotoCount = groupMembers.Count(x => x.State == (byte)GroupMemberState.Approved && x.User.Avatar == null);

                if (string.IsNullOrWhiteSpace(query))
                {
                    Members = groupMembers.Where(x => x.State == (byte)GroupMemberState.Approved && x.User.Avatar != null)
                        .OrderBy(x => Guid.NewGuid()).Take(ShowCount).Select(x => new GroupMembers_MemberViewModel(x)).ToList();
                }
                else
                {
                    Query = query;

                    var fullnamed = groupMembers
                        .Where(x => !string.IsNullOrEmpty(x.User.SurName) && !string.IsNullOrEmpty(x.User.FirstName) &&
                            query.Contains(x.User.SurName) && query.Contains(x.User.FirstName));
                    var lastnamed = groupMembers.Where(x => !string.IsNullOrEmpty(x.User.SurName) && query.Contains(x.User.SurName));
                    var firstnamed = groupMembers.Where(x => !string.IsNullOrEmpty(x.User.FirstName) && query.Contains(x.User.FirstName));

                    Members = fullnamed.Union(lastnamed.Union(firstnamed)).Distinct().Take(ShowCount).Select(x => new GroupMembers_MemberViewModel(x)).ToList();
                }
            }
        }
示例#28
0
        public GroupExpertsViewModel(Group group, Guid? filterByTag = null)
        {
            GroupId = group.Id;
            GroupUrl = group.Url;
            FilterTagId = filterByTag;
            Experts = new List<GroupExperts_ExpertViewModel>();

            if (UserContext.Current.IsUserApprovedInGroup(group.Id))
            {
                var uig = GroupService.UserInGroup(UserContext.Current.Id, group);

                if (uig.Expert != null)
                    IsExpert = true;
            }

            List<Expert> experts;
            if(filterByTag!=null)
            {
                var filterTag = DataService.PerThread.TagSet.SingleOrDefault(x => x.Id == filterByTag);
                if (filterTag != null)
                {
                    experts =
                        DataService.PerThread.ExpertSet.Where(
                            x => x.GroupMember.GroupId == GroupId).ToList().Where(x => x.Tags.Contains(filterTag) && x.Tags.Count > 0).ToList();

                    FilterTagTitle = filterTag.Title;
                }
                else
                {
                    FilterTagId = null;
                    experts = DataService.PerThread.ExpertSet.Where(x => x.GroupMember.GroupId == GroupId && x.Tags.Count > 0 ).ToList();
                }
            }
            else
                experts = DataService.PerThread.ExpertSet.Where(x => x.GroupMember.GroupId == GroupId && x.Tags.Count > 0).ToList();

            foreach (var expert in experts)
                Experts.Add(new GroupExperts_ExpertViewModel(expert));
        }
示例#29
0
        public GroupDetailsViewModel(Group group, Guid? userId = null)
        {
            if (group != null)
            {
                GroupId = group.Id;
                Url = group.Url;

                Logo = group.Logo;
                Name = group.Name;
                Summary = group.Summary;
                PollQuorum = group.PollQuorum;
                ElectionQuorum = group.ElectionQuorum;

                if (group.Categories.Count > 0)
                    Category = group.Categories.First().Title;

                IsContentModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);
                IsMemberModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.MemberModeration);
                IsPrivateDiscussion = group.PrivacyEnum.HasFlag(GroupPrivacy.PrivateDiscussion);

                Badges = new _BadgesViewModel(group);
                MembersCount = group.GroupMembers.Count(gm => gm.State == (byte)GroupMemberState.Approved || gm.State == (byte)GroupMemberState.Moderator);
                MaxModeratorsCount = group.ModeratorsCount;

                ModeratorList = new Group_ModersViewModel(group);

                Topics = group.Tags.Where(x => x.TopicState == (byte)TopicState.GroupTopic).OrderByDescending(x=>x.LowerTitle).Select(x=>new TagViewModel(x)).ToList();
                Tags = group.Tags.Where(x => x.TopicState != (byte)TopicState.GroupTopic).OrderByDescending(x => x.Weight).Select(x => new TagViewModel(x)).Take(50).ToList();

                if (userId.HasValue)
                {
                    var uig = GroupService.UserInGroup(userId.Value, group.Id);

                    if (uig != null && uig.State == (byte)GroupMemberState.Moderator)
                        ProposedTags = group.Tags.Where(x => x.TopicState == (byte)TopicState.ProposedTopic).Select(x => new TagViewModel(x)).ToList();
                }
            }
        }
        public GroupCreatePollViewModel(Group group)
        {
            Duration = 7;

            if (group != null)
            {
                GroupId = group.Id;
                GroupName = group.Name;
                GroupUrl = group.Url;
                IsContentModeration = group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);

                if (GroupId == new Guid(ConstHelper.KsGroupId))
                {
                    HasOpenProtocol = true;
                }

                Topics = group.Tags.Where(t => t.TopicState == (byte)TopicState.GroupTopic).Select(x => new TagViewModel(x)).ToList();
            }
            else
            {
                Topics = new List<TagViewModel>();
            }
        }