Merge branch 'unstable' into 'main'
Completion update See merge request internship-2025/survey-webapp/surveylib!16
This commit is contained in:
commit
7d47ab9e60
7 changed files with 27 additions and 8 deletions
|
|
@ -4,7 +4,9 @@ public class Completion
|
|||
{
|
||||
public int Id { get; set; }
|
||||
public int SurveyId { get; set; }
|
||||
public DateTime FinishedAt { get; set; }
|
||||
public DateTime FinishedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public int? CompletedBy { get; set; }
|
||||
|
||||
public Survey Survey { get; set; }
|
||||
public ICollection<Answer> Answers { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ namespace SurveyLib.Core.Repositories;
|
|||
public interface IAnswerRepository : IGenericRepository<Answer>
|
||||
{
|
||||
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>
|
||||
{
|
||||
|
||||
Task<IEnumerable<Completion>> GetCompletionsBySurveyIdAsync(int surveyId);
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@ namespace SurveyLib.Core.Services;
|
|||
|
||||
public interface IAnswerService
|
||||
{
|
||||
Task<bool> AddAnswerAsync(Answer answer);
|
||||
Task<bool> UpdateAnswerAsync(Answer answer);
|
||||
Task<bool> DeleteAnswerAsync(int id);
|
||||
Task AddAnswerAsync(Answer answer);
|
||||
Task UpdateAnswerAsync(Answer answer);
|
||||
Task DeleteAnswerAsync(int id);
|
||||
Task<IEnumerable<Answer>> GetAnswersByCompletionIdAsync(int completionId);
|
||||
Task<IEnumerable<Answer>> GetAnswersByQuestionIdAsync(int questionId);
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ namespace SurveyLib.Core.Services;
|
|||
|
||||
public interface ICompletionService
|
||||
{
|
||||
Task<bool> AddCompletionAsync(Completion completion);
|
||||
Task<bool> UpdateCompletionAsync(Completion completion);
|
||||
Task<bool> DeleteCompletionAsync(int id);
|
||||
Task AddCompletionAsync(Completion completion);
|
||||
Task UpdateCompletionAsync(Completion completion);
|
||||
Task DeleteCompletionAsync(int id);
|
||||
Task<IEnumerable<Completion>> GetCompletionsBySurveyIdAsync(int surveyId);
|
||||
}
|
||||
|
|
@ -47,4 +47,14 @@ public class AnswerRepository : IAnswerRepository
|
|||
.ExecuteDeleteAsync();
|
||||
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.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