diff --git a/SurveyLib.Infrastructure.EFCore/Repositories/AnswerRepository.cs b/SurveyLib.Infrastructure.EFCore/Repositories/AnswerRepository.cs index fb77da5..d71e0a7 100644 --- a/SurveyLib.Infrastructure.EFCore/Repositories/AnswerRepository.cs +++ b/SurveyLib.Infrastructure.EFCore/Repositories/AnswerRepository.cs @@ -14,38 +14,41 @@ public class AnswerRepository : IAnswerRepository _context = context; } - public Task GetByIdAsync(int id) + public async Task GetByIdAsync(int id) { throw new NotImplementedException(); } - public Task> GetAllAsync() + public async Task> GetAllAsync() { - throw new NotImplementedException(); + return await _context.Answers.ToListAsync(); } - public Task AddAsync(Answer entity) + public async Task AddAsync(Answer entity) { - throw new NotImplementedException(); + await _context.Answers.AddAsync(entity); + await _context.SaveChangesAsync(); } - public Task UpdateAsync(Answer entity) + public async Task UpdateAsync(Answer entity) { - throw new NotImplementedException(); + _context.Answers.Update(entity); + await _context.SaveChangesAsync(); } - public Task DeleteAsync(Answer entity) + public async Task DeleteAsync(Answer entity) { - throw new NotImplementedException(); + _context.Answers.Remove(entity); + await _context.SaveChangesAsync(); } - public Task> GetByAttemptIdAsync(int attemptId) + public async Task> GetByAttemptIdAsync(int attemptId) { - throw new NotImplementedException(); + return await _context.Answers.Where(a => a.CompletionId == attemptId).ToListAsync(); } - public Task> GetByQuestionIdAsync(int questionId) + public async Task> GetByQuestionIdAsync(int questionId) { - throw new NotImplementedException(); + return await _context.Answers.Where(a => a.QuestionId == questionId).ToListAsync(); } } \ No newline at end of file