Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Delete(Guid groupId, Guid documentId)
        {
            var document = await _groupDocumentsService.GetAsync(documentId);

            if (document.GroupId != groupId)
            {
                throw new Exception("Can't delete document because it does not belong to this group!");
            }

            var currentUserId = await _intranetMemberService.GetCurrentMemberIdAsync();

            var group = await _groupService.GetAsync(groupId);

            var groupMembers = await _groupMemberService.GetGroupMemberByGroupAsync(groupId);

            var media     = _mediaService.Get(document.MediaId);
            var canDelete = CanDelete(currentUserId, group, groupMembers, media);

            if (canDelete)
            {
                _mediaService.Remove(media.Id);
                await _groupDocumentsService.DeleteAsync(document);

                return(Ok());
            }

            return(BadRequest());
        }
Ejemplo n.º 2
0
        private FolderModel CreateMediaFolder(Enum mediaFolderType)
        {
            var mediaFolderTypeEnum = (MediaFolderTypeEnum)mediaFolderType;
            var folderName          = mediaFolderTypeEnum.GetAttribute <DisplayAttribute>().Name;
            var mediaFolder         = _mediaService.CreateMedia(folderName, -1, FolderTypeAlias);

            mediaFolder.SetValue(FolderConstants.FolderTypePropertyTypeAlias, mediaFolderType.ToString());
            _mediaService.Save(mediaFolder);

            return(_mediaModelService.Get <FolderModel>(mediaFolder.Id));
        }
Ejemplo n.º 3
0
        public GroupViewModel GetGroupViewModel(Guid groupId)
        {
            var group = _groupService.Get(groupId);

            var currentMemberId = _memberService.GetCurrentMemberId();

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

            groupModel.IsMember     = _groupMemberService.IsGroupMember(group.Id, currentMemberId);
            groupModel.IsCreator    = group.CreatorId == currentMemberId;
            groupModel.MembersCount = _groupMemberService.GetMembersCount(group.Id);
            groupModel.Creator      = _memberService.Get(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);
        }