This commit is contained in:
mmrbnjd
2024-04-17 15:49:34 +03:30
parent f829d80851
commit 3f0a37a08b
27 changed files with 1253 additions and 79 deletions

View File

@@ -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);

View File

@@ -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)
{