using System.Linq.Expressions; using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core.Models; using Microsoft.EntityFrameworkCore; namespace BlackRock.Reporting.API.Persistence { // Q: Da li da dozvolimo promene van klase ili da zabranimo pomocu AsNoTracking(); public class Repository : IRepository where TEntity : class { private readonly BRDbContext context; public Repository(BRDbContext context) { this.context = context; } public async Task> GetAllAsync() { var result = await context.Set().ToListAsync(); return result.AsQueryable(); } public async Task GetByIdAsync(Guid id) { return await context.Set() .FindAsync(id); } public async Task AddAsync(TEntity entity) { await context.Set().AddAsync(entity); } public async Task AddRangeAsync(IEnumerable entities) { await context.Set().AddRangeAsync(entities); } public void Remove(TEntity entity) { context.Set().Remove(entity); } public void RemoveRange(IEnumerable entities) { context.Set().RemoveRange(entities); } } }