added repository interfaces for all models
added Completion model
This commit is contained in:
parent
468ddba909
commit
18840fc224
9 changed files with 51 additions and 6 deletions
|
|
@ -2,11 +2,10 @@ namespace SurveyLib.Core.Models;
|
||||||
|
|
||||||
public class Answer
|
public class Answer
|
||||||
{
|
{
|
||||||
public int TryId { get; set; }
|
public int CompletionId { get; set; }
|
||||||
public int SurveyId { get; set; }
|
|
||||||
public int QuestionId { get; set; }
|
public int QuestionId { get; set; }
|
||||||
public string AnswerText { get; set; }
|
public string AnswerText { get; set; }
|
||||||
|
|
||||||
public Survey Survey { get; set; }
|
public Completion Completion { get; set; }
|
||||||
public QuestionBase Question { get; set; }
|
public QuestionBase Question { get; set; }
|
||||||
}
|
}
|
||||||
10
SurveyLib.Core/Models/Completion.cs
Normal file
10
SurveyLib.Core/Models/Completion.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
public class Completion
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int SurveyId { get; set; }
|
||||||
|
public DateTime FinishedAt { get; set; }
|
||||||
|
|
||||||
|
public Survey Survey { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ namespace SurveyLib.Core.Models;
|
||||||
|
|
||||||
public class QuestionBase
|
public class QuestionBase
|
||||||
{
|
{
|
||||||
public int Id { get; set; } // TODO: А ведь их наверное много будет, вдруг int однажды не хватит...
|
public int Id { get; set; }
|
||||||
public int SurveyId { get; set; }
|
public int SurveyId { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ public class Survey
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public ICollection<QuestionBase> Questions { get; set; }
|
public ICollection<QuestionBase> Questions { get; set; }
|
||||||
public ICollection<Answer> Answers { get; set; }
|
public ICollection<Completion> Completions { get; set; }
|
||||||
}
|
}
|
||||||
9
SurveyLib.Core/Repositories/IAnswerRepository.cs
Normal file
9
SurveyLib.Core/Repositories/IAnswerRepository.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
namespace SurveyLib.Core.Repositories;
|
||||||
|
|
||||||
|
public interface IAnswerRepository : IGenericRepository<Answer>
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Answer>> GetByAttemptIdAsync(int attemptId);
|
||||||
|
Task<IEnumerable<Answer>> GetByQuestionIdAsync(int questionId);
|
||||||
|
}
|
||||||
8
SurveyLib.Core/Repositories/ICompletionRepository.cs
Normal file
8
SurveyLib.Core/Repositories/ICompletionRepository.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
using SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
namespace SurveyLib.Core.Repositories;
|
||||||
|
|
||||||
|
public interface ICompletionRepository : IGenericRepository<Completion>
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Completion>> GetBySurveyIdAsync(int surveyId);
|
||||||
|
}
|
||||||
9
SurveyLib.Core/Repositories/IQuestionRepository.cs
Normal file
9
SurveyLib.Core/Repositories/IQuestionRepository.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
namespace SurveyLib.Core.Repositories;
|
||||||
|
|
||||||
|
public interface IQuestionRepository : IGenericRepository<QuestionBase>
|
||||||
|
{
|
||||||
|
Task<QuestionBase?> GetWithAnswersAsync(int questionId);
|
||||||
|
Task<IEnumerable<QuestionBase>> GetBySurveyIdAsync(int surveyId);
|
||||||
|
}
|
||||||
10
SurveyLib.Core/Repositories/ISurveyRepository.cs
Normal file
10
SurveyLib.Core/Repositories/ISurveyRepository.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
using SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
namespace SurveyLib.Core.Repositories;
|
||||||
|
|
||||||
|
public interface ISurveyRepository : IGenericRepository<Survey>
|
||||||
|
{
|
||||||
|
Task<Survey?> GetWithQuestionsAsync(int surveyId);
|
||||||
|
Task<Survey?> GetWithCompletionsAsync(int surveyId);
|
||||||
|
Task<Survey?> FindByTitleAsync(string title);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue