This commit is contained in:
2023-06-17 14:16:09 +03:00
parent 62178f1f32
commit 7ae5d3bc81
180 changed files with 12932 additions and 192 deletions
+14 -8
View File
@@ -39,30 +39,34 @@ public class RepositoryBase<TEntity> where TEntity : class
}
protected async Task<TEntity?> GetAsync(Guid id)
protected async Task<TEntity?> GetBaseAsync(Guid id)
{
return await _context.Set<TEntity>().FindAsync(id);
}
protected async Task<int> AddAsync(TEntity entity)
protected async Task<int> AddBaseAsync(TEntity entity)
{
await _context.Set<TEntity>().AddAsync(entity);
//await _context.Set<TEntity>().AddAsync(entity);
await _context.AddAsync(entity);
return await SaveChangesAsync();
}
protected int Add(TEntity entity)
protected int AddBase(TEntity entity)
{
_context.Set<TEntity>().Add(entity);
//_context.Set<TEntity>().Add(entity);
_context.Add(entity);
return SaveChanges();
}
protected int Remove(TEntity entity)
protected int RemoveBase(TEntity entity)
{
_context.Set<TEntity>().Remove(entity);
_context.Entry(entity).State = EntityState.Deleted;
return SaveChanges();
}
protected async Task<int> UpdateAsync(TEntity entity)
protected async Task<int> UpdateBaseAsync(TEntity entity)
{
_context.Attach(entity);
_context.Entry(entity).State = EntityState.Modified;
@@ -70,9 +74,11 @@ public class RepositoryBase<TEntity> where TEntity : class
return await SaveChangesAsync();
}
protected int Update(TEntity entity)
protected int UpdateBase(TEntity entity)
{
_context.Attach(entity);
_context.Entry(entity).State = EntityState.Modified;
return SaveChanges();
}
}