Beispiel #1
0
        public async Task DeleteGroupAsync(EntityDto <long> input)
        {
            var isSystemGroup = Enum.IsDefined(typeof(DefaultGroups), (int)input.Id);

            if (isSystemGroup)
            {
                throw new UserFriendlyException("PictureGallery.Group.SystemGroup.CantNotDelete");
            }

            var pictureGroup = await _pictureManager.GetGroupByIdAsync(input.Id);

            //无法删除系统分组
            if (pictureGroup.IsSystemGroup)
            {
                throw new UserFriendlyException("PictureGallery.Group.SystemGroup.CantNotDelete");
            }

            var pictures = await _pictureManager.Pictures.Where(p => p.GroupId == pictureGroup.Id).ToListAsync();

            pictures.Each(t => t.GroupId = 0);

            await _pictureManager.DeleteGroupAsync(pictureGroup);
        }