mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-10-31 02:27:04 -04:00 
			
		
		
		
	* Removed some extra spam for the console * Implemented the code to update RowVersion, which is our concurrency check * Fixed a critical issue where more than one bookmark could occur for a given chapter due to a race condition. Now we use concurrency checks and we also gracefully allow more than one row, by only grabbing first. * Cleaned up the logic for IHasConcurencyToken and updated the setters to be private. * Lots of comments and when deleting a library, remove any user progress items for which chapters don't exist. * When deleting a Series, cleanup user progress rows. * Now after a scan of library, if a series is removed, collection tags are pruned as well if there are no longer any series bound to it. * Updated the image on the Readme to show a better picture * Small code cleanup to remove null check modifier as I check for null just before then * Fixed images loading multiple times due to using function in binding with random. You can now click chapter images to read that chapter specifically. * Fixed cards being different sizes when read vs unread * Moved over Robbie's workflow changes from notifier. Commented out activity indicators as that is not shipping with this release. * Remove code that isn't needed * Reverted GA * Changed GA to trigger only when HEAD is updated
		
			
				
	
	
		
			83 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Threading.Tasks;
 | |
| using API.Entities;
 | |
| using API.Interfaces;
 | |
| using API.Interfaces.Repositories;
 | |
| using AutoMapper;
 | |
| using Microsoft.AspNetCore.Identity;
 | |
| 
 | |
| namespace API.Data
 | |
| {
 | |
|     public class UnitOfWork : IUnitOfWork
 | |
|     {
 | |
|         private readonly DataContext _context;
 | |
|         private readonly IMapper _mapper;
 | |
|         private readonly UserManager<AppUser> _userManager;
 | |
| 
 | |
|         public UnitOfWork(DataContext context, IMapper mapper, UserManager<AppUser> userManager)
 | |
|         {
 | |
|             _context = context;
 | |
|             _mapper = mapper;
 | |
|             _userManager = userManager;
 | |
|         }
 | |
| 
 | |
|         public ISeriesRepository SeriesRepository => new SeriesRepository(_context, _mapper);
 | |
|         public IUserRepository UserRepository => new UserRepository(_context, _userManager, _mapper);
 | |
|         public ILibraryRepository LibraryRepository => new LibraryRepository(_context, _mapper);
 | |
| 
 | |
|         public IVolumeRepository VolumeRepository => new VolumeRepository(_context, _mapper);
 | |
| 
 | |
|         public ISettingsRepository SettingsRepository => new SettingsRepository(_context, _mapper);
 | |
| 
 | |
|         public IAppUserProgressRepository AppUserProgressRepository => new AppUserProgressRepository(_context);
 | |
|         public ICollectionTagRepository CollectionTagRepository => new CollectionTagRepository(_context, _mapper);
 | |
|         public IFileRepository FileRepository => new FileRepository(_context);
 | |
|         public IChapterRepository ChapterRepository => new ChapterRepository(_context);
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Commits changes to the DB. Completes the open transaction.
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public bool Commit()
 | |
|         {
 | |
| 
 | |
|             return _context.SaveChanges() > 0;
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// Commits changes to the DB. Completes the open transaction.
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public async Task<bool> CommitAsync()
 | |
|         {
 | |
|             return await _context.SaveChangesAsync() > 0;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Is the DB Context aware of Changes in loaded entities
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public bool HasChanges()
 | |
|         {
 | |
|             return _context.ChangeTracker.HasChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Rollback transaction
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public async Task<bool> RollbackAsync()
 | |
|         {
 | |
|             await _context.DisposeAsync();
 | |
|             return true;
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// Rollback transaction
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public bool Rollback()
 | |
|         {
 | |
|             _context.Dispose();
 | |
|             return true;
 | |
|         }
 | |
|     }
 | |
| }
 |