Merge branch 'unstable' into 'main'
Added basic version of models and interfaces See merge request internship-2025/survey-webapp/surveylib!3
This commit is contained in:
commit
7c5c6d1a19
10 changed files with 90 additions and 5 deletions
|
|
@ -1,5 +0,0 @@
|
||||||
namespace SurveyLib.Core;
|
|
||||||
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
}
|
|
||||||
11
SurveyLib.Core/Models/Answer.cs
Normal file
11
SurveyLib.Core/Models/Answer.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
public class Answer
|
||||||
|
{
|
||||||
|
public int CompletionId { get; set; }
|
||||||
|
public int QuestionId { get; set; }
|
||||||
|
public string AnswerText { get; set; }
|
||||||
|
|
||||||
|
public Completion Completion { get; set; }
|
||||||
|
public QuestionBase Question { get; set; }
|
||||||
|
}
|
||||||
11
SurveyLib.Core/Models/Completion.cs
Normal file
11
SurveyLib.Core/Models/Completion.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
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; }
|
||||||
|
public ICollection<Answer> Answers { get; set; }
|
||||||
|
}
|
||||||
11
SurveyLib.Core/Models/QuestionBase.cs
Normal file
11
SurveyLib.Core/Models/QuestionBase.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
public class QuestionBase
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int SurveyId { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
public Survey Survey { get; set; }
|
||||||
|
public ICollection<Answer> Answers { get; set; }
|
||||||
|
}
|
||||||
11
SurveyLib.Core/Models/Survey.cs
Normal file
11
SurveyLib.Core/Models/Survey.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace SurveyLib.Core.Models;
|
||||||
|
|
||||||
|
public class Survey
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
public ICollection<QuestionBase> Questions { 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);
|
||||||
|
}
|
||||||
10
SurveyLib.Core/Repositories/IGenericRepository.cs
Normal file
10
SurveyLib.Core/Repositories/IGenericRepository.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace SurveyLib.Core.Repositories;
|
||||||
|
|
||||||
|
public interface IGenericRepository<T> where T : class
|
||||||
|
{
|
||||||
|
Task<T>? GetByIdAsync(int id);
|
||||||
|
Task<IEnumerable<T>> GetAllAsync();
|
||||||
|
Task AddAsync(T entity);
|
||||||
|
Task UpdateAsync(T entity);
|
||||||
|
Task DeleteAsync(T entity);
|
||||||
|
}
|
||||||
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