using Microsoft.EntityFrameworkCore; using SurveyLib.Core.Models; using SurveyLib.Core.Repositories; using SurveyLib.Infrastructure.EFCore.Data; namespace SurveyLib.Infrastructure.EFCore.Repositories; public class CompletionRepository : ICompletionRepository { private readonly SurveyDbContext _context; public CompletionRepository(SurveyDbContext context) { _context = context; } public async Task GetByIdAsync(int id) { return await _context.Completions.FindAsync(id); } public async Task> GetAllAsync() { return await _context.Completions.ToListAsync(); } public async Task AddAsync(Completion entity) { await _context.Completions.AddAsync(entity); await _context.SaveChangesAsync(); } public async Task UpdateAsync(Completion entity) { _context.Completions.Update(entity); await _context.SaveChangesAsync(); } public async Task DeleteAsync(int id) { await _context.Completions.Where(c => c.Id == id).ExecuteDeleteAsync(); await _context.SaveChangesAsync(); } }