Transaction Support (#309)

* Added transactions to UnitOfWork and refactored code to use it.

* This included blank UI fix from Kavita-webui
This commit is contained in:
Joseph Milazzo 2021-06-18 07:37:48 -05:00 committed by GitHub
parent d2e444910d
commit 6e1b227e65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 168 additions and 124 deletions

View file

@ -30,7 +30,11 @@ namespace API.Data
public IAppUserProgressRepository AppUserProgressRepository => new AppUserProgressRepository(_context);
public ICollectionTagRepository CollectionTagRepository => new CollectionTagRepository(_context, _mapper);
public async Task<bool> Complete()
public bool Commit()
{
return _context.SaveChanges() > 0;
}
public async Task<bool> CommitAsync()
{
return await _context.SaveChangesAsync() > 0;
}
@ -39,5 +43,16 @@ namespace API.Data
{
return _context.ChangeTracker.HasChanges();
}
public async Task<bool> RollbackAsync()
{
await _context.DisposeAsync();
return true;
}
public bool Rollback()
{
_context.Dispose();
return true;
}
}
}