public async Task DeleteRepositoryAsync(int repoId)
        {
            var user = await _auth.GetCurrentUserAsync();

            var repo = await _context.Set <Repository>()
                       .FindAsync(repoId);

            if (repo == null)
            {
                throw new NotFoundException();
            }
            if (repo.UserId != user.Id)
            {
                throw new AccessDeniedException();
            }

            using var transaction = await _context.Database.BeginTransactionAsync();

            _context.Remove(repo);
            await _context.SaveChangesAsync();

            await _directoryManager.DeleteDirectoryAsync(repo.RootId, noTransaction : true);

            await transaction.CommitAsync();
        }
Exemple #2
0
        public async Task <ActionResult> DeleteDirectory(int directoryId)
        {
            await _dirManager.DeleteDirectoryAsync(directoryId);

            return(Ok());
        }