completed CompletionRepository.cs

This commit is contained in:
Вячеслав 2025-03-14 23:22:13 +05:00
parent 62facb3423
commit 8fc3932df3

View file

@ -1,3 +1,4 @@
using Microsoft.EntityFrameworkCore;
using SurveyLib.Core.Models; using SurveyLib.Core.Models;
using SurveyLib.Core.Repositories; using SurveyLib.Core.Repositories;
using SurveyLib.Infrastructure.EFCore.Data; using SurveyLib.Infrastructure.EFCore.Data;
@ -13,33 +14,36 @@ public class CompletionRepository : ICompletionRepository
_context = context; _context = context;
} }
public Task<Completion?> GetByIdAsync(int id) public async Task<Completion?> GetByIdAsync(int id)
{ {
throw new NotImplementedException(); return await _context.Completions.FirstOrDefaultAsync(c => c.Id == id);
} }
public Task<IEnumerable<Completion>> GetAllAsync() public async Task<IEnumerable<Completion>> GetAllAsync()
{ {
throw new NotImplementedException(); return await _context.Completions.ToListAsync();
} }
public Task AddAsync(Completion entity) public async Task AddAsync(Completion entity)
{ {
throw new NotImplementedException(); await _context.Completions.AddAsync(entity);
await _context.SaveChangesAsync();
} }
public Task UpdateAsync(Completion entity) public async Task UpdateAsync(Completion entity)
{ {
throw new NotImplementedException(); _context.Completions.Update(entity);
await _context.SaveChangesAsync();
} }
public Task DeleteAsync(Completion entity) public async Task DeleteAsync(Completion entity)
{ {
throw new NotImplementedException(); _context.Completions.Remove(entity);
await _context.SaveChangesAsync();
} }
public Task<IEnumerable<Completion>> GetBySurveyIdAsync(int surveyId) public async Task<IEnumerable<Completion>> GetBySurveyIdAsync(int surveyId)
{ {
throw new NotImplementedException(); return await _context.Completions.Where(c => c.SurveyId == surveyId).ToListAsync();
} }
} }