...
This commit is contained in:
@@ -28,6 +28,8 @@ namespace Back.Data.Contracts
|
||||
bool AddBoolResult(T entity);
|
||||
Task<bool> UpdateAsync(T entity);
|
||||
bool Update(T entity);
|
||||
Task<T?> UpdateByObjAsync(T entity);
|
||||
T? UpdateByObj(T entity);
|
||||
Task<bool> UpdateRangeAsync(ICollection<T> entites);
|
||||
bool UpdateRange(ICollection<T> entites);
|
||||
bool Delete(T entity);
|
||||
|
@@ -134,6 +134,36 @@ namespace Back.Data.Infrastructure.Repository
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<T?> UpdateByObjAsync(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_dbContext.Entry(entity).State = EntityState.Modified;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public T? UpdateByObj(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dbContext.Update(entity);
|
||||
var result = _dbContext.SaveChanges();
|
||||
return entity;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<bool> DeleteAsync(T entity)
|
||||
{
|
||||
|
Reference in New Issue
Block a user