Exemplo n.º 1
0
        private void DeleteFolder(int obj)
        {
            foreach (var n in NoteDTOs.ToList().Where(x => x.FolderId == obj))
            {
                NoteRepository.Delete(n);
                NoteDTOs.Remove(n);
            }

            foreach (var n in FolderDTOs.ToList().Where(x => x.ParentId == obj))
            {
                FolderRepository.Delete(n);
                FolderDTOs.Remove(n);
            }

            FolderRepository.Delete(FolderDTOs.Find(x => x.Id == obj));

            FolderDTOs.Remove(FolderDTOs.Find(x => x.Id == obj));
        }
        public ActionResult <Folder> DeleteFolder(int id)
        {
            Folder folder = _folderRepository.GetBy(id);

            if (folder == null)
            {
                return(NotFound());
            }
            _folderRepository.Delete(folder);
            _folderRepository.SaveChanges();
            return(folder);
        }
Exemplo n.º 3
0
 private void DeleteFoldersTree(IDalAppFolder folder)
 {
     foreach (var fileId in folder.InternalFoldersIds.ToList())
     {
         _fileRepository.Delete(_fileRepository.GetById(fileId));
     }
     foreach (var internalFolderId in folder.InternalFoldersIds.ToList())
     {
         DeleteFoldersTree(_folderRepository.GetById(internalFolderId));
     }
     _folderRepository.Delete(folder);
 }
Exemplo n.º 4
0
        private async Task DeleteFolder(Guid folderId)
        {
            var noteDatas = await noteQueryRepository.GetAll(x => x.FolderId == folderId);

            foreach (var noteData in noteDatas)
            {
                notificationService.CancelScheduled(noteData.Id);
            }
            await folderRepository.Delete(folderId);

            eventBus.Publish(new FolderDeletedEvent(folderId));
        }
Exemplo n.º 5
0
        public async Task <Unit> Handle(DeleteFolderCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var folder = await _mediator.Send(new GetFolderQuery(request.Id), cancellationToken);

                await _repository.Delete(folder.HierarchyId, cancellationToken);

                return(Unit.Value);
            }
            catch (Exception e)
            {
                throw new DeleteException(request.Id, e);
            }
        }
Exemplo n.º 6
0
 public async Task <bool> DeleteCollectPath(Models.CollectPath collectPath)
 {
     try
     {
         if (collectPath != null)
         {
             return(await _repository.Delete(collectPath));
         }
         return(false);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         return(false);
     }
 }
Exemplo n.º 7
0
        public async Task <ActionResultResponse> Delete(string tenantId, string userId, int folderId)
        {
            var folderInfo = await _folderRepository.GetInfo(tenantId, userId, folderId);

            if (folderInfo == null)
            {
                return(new ActionResultResponse(-1, _fileManagermentResourceResource.GetString("Folder does not exists. Please try again.")));
            }

            if (folderInfo.TenantId != tenantId)
            {
                return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission)));
            }

            // Check is has child.
            var folderChildCount = await _folderRepository.GetChildCount(folderInfo.Id);

            if (folderChildCount > 0)
            {
                return(new ActionResultResponse(-3,
                                                _fileManagermentResourceResource.GetString("This folder has children folder. You can not delete this folder.")));
            }

            var existsFileInFolder = await _fileRepository.CheckExistsByFolderId(folderId);

            if (existsFileInFolder)
            {
                return(new ActionResultResponse(-4,
                                                _fileManagermentResourceResource.GetString("This folder has children file. You can not delete this folder.")));
            }

            var result = await _folderRepository.Delete(tenantId, userId, folderInfo.Id);

            if (result > 0 && folderInfo.ParentId.HasValue)
            {
                //Update parent folder child count.
                var childCount = await _folderRepository.GetChildCount(folderInfo.ParentId.Value);

                await _folderRepository.UpdateChildCount(tenantId, userId, folderInfo.ParentId.Value, childCount);
            }
            return(new ActionResultResponse(result, result > 0
                ? _fileManagermentResourceResource.GetString("Delete folder successful.")
                : _sharedResourceService.GetString(ErrorMessage.SomethingWentWrong)));
        }
Exemplo n.º 8
0
 public void DeleteFolder(DtoFolder e)
 {
     folderRepository.Delete(e.ToDalFolder());
     uow.Commit();
 }