adapt repository features to services needs
This commit is contained in:
parent
3961dbeb69
commit
9f6d5b575e
4 changed files with 18 additions and 1 deletions
|
|
@ -5,4 +5,6 @@ namespace SurveyLib.Core.Repositories;
|
||||||
public interface IAnswerRepository : IGenericRepository<Answer>
|
public interface IAnswerRepository : IGenericRepository<Answer>
|
||||||
{
|
{
|
||||||
Task DeleteAsync(int questionId, int completionId);
|
Task DeleteAsync(int questionId, int completionId);
|
||||||
|
Task<IEnumerable<Answer>> GetAnswersByCompletionIdAsync(int completionId);
|
||||||
|
Task<IEnumerable<Answer>> GetAnswersByQuestionIdAsync(int questionId);
|
||||||
}
|
}
|
||||||
|
|
@ -4,5 +4,5 @@ namespace SurveyLib.Core.Repositories;
|
||||||
|
|
||||||
public interface ICompletionRepository : IGenericRepository<Completion>
|
public interface ICompletionRepository : IGenericRepository<Completion>
|
||||||
{
|
{
|
||||||
|
Task<IEnumerable<Completion>> GetCompletionsBySurveyIdAsync(int surveyId);
|
||||||
}
|
}
|
||||||
|
|
@ -47,4 +47,14 @@ public class AnswerRepository : IAnswerRepository
|
||||||
.ExecuteDeleteAsync();
|
.ExecuteDeleteAsync();
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Answer>> GetAnswersByCompletionIdAsync(int completionId)
|
||||||
|
{
|
||||||
|
return await _context.Answers.Where(a => a.CompletionId == completionId).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Answer>> GetAnswersByQuestionIdAsync(int questionId)
|
||||||
|
{
|
||||||
|
return await _context.Answers.Where(a => a.QuestionId == questionId).ToListAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -41,4 +41,9 @@ public class CompletionRepository : ICompletionRepository
|
||||||
await _context.Completions.Where(c => c.Id == id).ExecuteDeleteAsync();
|
await _context.Completions.Where(c => c.Id == id).ExecuteDeleteAsync();
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Completion>> GetCompletionsBySurveyIdAsync(int surveyId)
|
||||||
|
{
|
||||||
|
return await _context.Completions.Where(c => c.SurveyId == surveyId).ToListAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue