Commit 4b6e6961 authored by Almouhannad's avatar Almouhannad

(B) Fix base repo create bug

parent d9b88043
...@@ -29,7 +29,9 @@ public class Repositroy<TEntity> : IRepository<TEntity> where TEntity : Entity ...@@ -29,7 +29,9 @@ public class Repositroy<TEntity> : IRepository<TEntity> where TEntity : Entity
public async Task<TEntity> CreateAsync(TEntity entity) public async Task<TEntity> CreateAsync(TEntity entity)
{ {
return await _context.Set<TEntity>().FirstAsync(e => e.Id == entity.Id); var query = await _context.Set<TEntity>().AddAsync(entity);
await _context.SaveChangesAsync();
return query.Entity;
} }
#endregion #endregion
...@@ -43,7 +45,7 @@ public class Repositroy<TEntity> : IRepository<TEntity> where TEntity : Entity ...@@ -43,7 +45,7 @@ public class Repositroy<TEntity> : IRepository<TEntity> where TEntity : Entity
public async Task<ICollection<TEntity>> GetAllAsync() public async Task<ICollection<TEntity>> GetAllAsync()
{ {
return await _context.Set<TEntity>().ToListAsync<TEntity>(); return await _context.Set<TEntity>().ToListAsync();
} }
#endregion #endregion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment