Started the Split
Split Json data models coming from REST Api, from the Database models storing them in a SQLite database. Work to re-engineer endpoints to use Database objects, and copy/update data from the json objects. More work is needed.
This commit is contained in:
parent
157d46ee2e
commit
4985dc4179
36 changed files with 684 additions and 323 deletions
|
|
@ -5,22 +5,25 @@ namespace FreeTubeSync;
|
|||
|
||||
public class Repository<TEntity>(DataContext dbContext) : IRepository<TEntity> where TEntity : class
|
||||
{
|
||||
public async Task AddAsync(TEntity entity, CancellationToken ct)
|
||||
public async Task AddAsync(TEntity entity, CancellationToken ct, bool sync = true)
|
||||
{
|
||||
dbContext.Set<TEntity>().Add(entity);
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
if(sync)
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(TEntity entity, CancellationToken ct)
|
||||
public async Task UpdateAsync(TEntity entity, CancellationToken ct, bool sync = true)
|
||||
{
|
||||
dbContext.Set<TEntity>().Update(entity);
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
if (sync)
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(TEntity entity, CancellationToken ct)
|
||||
public async Task DeleteAsync(TEntity entity, CancellationToken ct, bool sync = true)
|
||||
{
|
||||
dbContext.Set<TEntity>().Remove(entity);
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
if (sync)
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<TEntity?> GetByIdAsync(string id, CancellationToken ct)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue