Exemple #1
0
        /// <summary>
        /// Deletes the root album for the current gallery and all child items, but leaves the directories and original files on disk.
        /// This function also deletes the metadata for the root album, which will leave it in an invalid state. For this reason,
        /// call this function *only* when also deleting the gallery the album is in.
        /// </summary>
        private void DeleteRootAlbum()
        {
            // Step 1: Delete the root album contents
            var rootAlbum = Factory.LoadRootAlbumInstance(GalleryId);

            rootAlbum.DeleteFromGallery();

            // Step 2: Delete all metadata associated with the root album of this gallery
            using (var repo = new MetadataRepository())
            {
                foreach (var dto in repo.Where(m => m.FKAlbumId == rootAlbum.Id))
                {
                    repo.Delete(dto);
                }
                repo.Save();
            }
        }
Exemple #2
0
        public async Task <IActionResult> Delete(int id)
        {
            string currentUser = HttpContext.User.Identity.Name;

            MetadataEntity origItem = _metadataRepository.GetById(id, true, true);

            if (origItem == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentDelete, "Metadata", id.ToString()));
            }

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Delete, origItem.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentDelete, "Metadata", id.ToString()));
            }

            foreach (var oldVer in origItem.Versions)
            {
                await _documentRepository.DeleteDocumentVersionAsync(oldVer);

                _logger.Log(LogLevel.Debug, "Document File:'{0}' Deleted By {1}", oldVer.GetServerFileName(), currentUser);
                _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentVersionDelete, oldVer.Id, "DocumentVersion", true);
            }

            await _documentRepository.DeleteDocumentAsync(origItem);

            _logger.Log(LogLevel.Debug, "Document File:'{0}' Deleted By {1}", origItem.GetServerFileName(), currentUser);

            _metadataRepository.Delete(origItem);

            _logger.Log(LogLevel.Debug, "Document {0} Deleted By {1}", origItem.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentDelete, id, "Document", true);

            _metadataRepository.SaveChanges();

            return(Ok());
        }
Exemple #3
0
        /// <summary>
        /// Deletes the root album for the current gallery and all child items, but leaves the directories and original files on disk.
        /// This function also deletes the metadata for the root album, which will leave it in an invalid state. For this reason, 
        /// call this function *only* when also deleting the gallery the album is in.
        /// </summary>
        private void DeleteRootAlbum()
        {
            // Step 1: Delete the root album contents
            var rootAlbum = Factory.LoadRootAlbumInstance(GalleryId);
            rootAlbum.DeleteFromGallery();

            // Step 2: Delete all metadata associated with the root album of this gallery
            using (var repo = new MetadataRepository())
            {
                foreach (var dto in repo.Where(m => m.FKAlbumId == rootAlbum.Id))
                {
                    repo.Delete(dto);
                }
                repo.Save();
            }
        }