using Microsoft.EntityFrameworkCore; using Renis.Database; using Renis.Database.Models; namespace Renis.Repositories; public class PolisRepository(ApplicationContext db) : IPolisRepository { private readonly ApplicationContext _db = db; public async Task AddPolis(Polis polis) { _db.Polises.Add(polis); return await Save(); } public async Task DeletePolis(Polis polis) { _db.Polises.Remove(polis); return await Save(); } public async Task GetPolisById(long id) { return await _db.Polises.FirstOrDefaultAsync(x => x.Id == id); } public async Task GetPolisByNumber(string number) { return await _db.Polises.FirstOrDefaultAsync(x => x.Number == number); } public IQueryable GetPolises() { return _db.Polises.AsQueryable(); } public async Task Save() { return await _db.SaveChangesAsync() > 0; } public async Task UpdatePolis(Polis polis) { _db.Polises.Update(polis); return await Save(); } }