Exemple #1
0
        public async Task <GroupViewModel> GetGroupViewModelAsync(Guid groupId)
        {
            var group = await _groupService.GetAsync(groupId);

            var currentMemberId = await _memberService.GetCurrentMemberIdAsync();

            var groupModel = group.Map <GroupViewModel>();

            groupModel.IsMember = await _groupMemberService.IsGroupMemberAsync(group.Id, currentMemberId);

            groupModel.IsCreator    = group.CreatorId == currentMemberId;
            groupModel.MembersCount = await _groupMemberService.GetMembersCountAsync(group.Id);

            groupModel.Creator  = (await _memberService.GetAsync(group.CreatorId)).ToViewModel();
            groupModel.GroupUrl = _groupLinkProvider.GetGroupRoomLink(group.Id);

            if (groupModel.HasImage)
            {
                groupModel.GroupImageUrl = _imageHelper.GetImageWithPreset(_mediaModelService.Get(group.ImageId.Value).Url, UmbracoAliases.ImagePresets.GroupImageThumbnail);
            }

            return(groupModel);
        }