コード例 #1
0
        public ActionResult Delete()
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia))
            {
                Services.Notifier.Error(T("Couldn't delete media folder"));
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new MediaManagerFolderEditViewModel();

            UpdateModel(viewModel);

            if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.DeleteMediaContent, viewModel.FolderPath))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                _mediaLibraryService.DeleteFolder(viewModel.FolderPath);
                Services.Notifier.Success(T("Media folder deleted"));
            }
            catch (ArgumentException argumentException) {
                Services.Notifier.Error(T("Deleting Folder failed: {0}", argumentException.Message));
                Services.TransactionManager.Cancel();
                return(View(viewModel));
            }

            return(RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" }));
        }
コード例 #2
0
        public void DeleteImageGallery(string name)
        {
            var gallerySettings = GetImageGallerySettings(GetMediaPath(name));

            foreach (ImageGalleryImage image in GetImageGallery(name).Images)
            {
                DeleteImage(name, image.Name, GetImageSettings(gallerySettings, image.Name));
            }

            if (gallerySettings != null)
            {
                _repository.Delete(gallerySettings);
            }
            _mediaService.DeleteFolder(GetMediaPath(name));
        }
コード例 #3
0
        public async Task <ActionResult> DeleteFolder([FromQuery] string folderId)
        {
            await _mediaLibraryService.DeleteFolder(folderId);

            return(Ok());
        }