예제 #1
0
        public IActionResult Delete(int id)
        {
            var file = _filesService.GetFile(id);

            if (file == null)
            {
                return(NotFound());
            }

            if (file.IsFolder)
            {
                var filesDeleted = _filesService.DeleteFolder(id);
                _logger.LogInformation("{n} files deleted.", filesDeleted);
            }
            else
            {
                var versionsDeleted = _filesService.DeleteFile(id);
                _logger.LogInformation("{n} versions of {file} deleted.", versionsDeleted, id);
            }

            if (file.ParentId != null)
            {
                return(RedirectToAction("View", "Folders", new { id = file.ParentId }));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }