You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.01-QCM_MuscuMaths/WebApi/ManagerInterfaces/IQuestionManager.cs

127 lines
5.0 KiB

using OrderCriterias;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ManagerInterfaces
{
/// <summary>
/// All methods to handle questions
/// /!\ all methods returns a task
/// </summary>
/// <typeparam name="T">a DTO, Entity or Model question</typeparam>
public interface IQuestionManager<T>
{
/// <summary>
/// get the number of questions
/// </summary>
/// <returns>the number of questions</returns>
public int getNbQuestions();
/// <summary>
/// add a question
/// </summary>
/// <param name="question">the question to add</param>
/// <returns>the question added</returns>
public Task<T> addQuestion(T question);
/// <summary>
/// delete a question
/// </summary>
/// <param name="question">the question to remove</param>
/// <returns>
/// the question deleted or
/// null if there isn't any
/// </returns>
public Task<T?> removeQuestion(T question);
/// <summary>
/// delete a question with an id
/// </summary>
/// <param name="id">the id of the question</param>
/// <returns>
/// the question deleted that corresponde
/// to the id or null if there isn't any
/// </returns>
public Task<T?> removeQuestion(int id);
/// <summary>
/// get a part of all questions
/// </summary>
/// <param name="nb">the actual page</param>
/// <param name="count">number of question in a page</param>
/// <param name="orderCriteria">the order criteria</param>
/// <returns>
/// a set of the number of page and
/// all questions in the database for
/// the page nb (or null if the page
/// does not exist (<=> (nb-1)*count outside
/// boundaries (0, getNbElement()-1)))
/// </returns>
public Task<(int nbPages, IEnumerable<T>? questions)> getQuestions(int nb, int count, QuestionOrderCriteria orderCriteria = QuestionOrderCriteria.ById);
/// <summary>
/// get a question with an id
/// </summary>
/// <param name="id">the id of the question</param>
/// <returns>
/// the question that corresponde
/// to the id or null if there isn't any
/// </returns>
public Task<T?> getQuestion(int id);
/// <summary>
/// get a question with a content
/// </summary>
/// <param name="content">the content of the question</param>
/// <returns>
/// the question that corresponde
/// to the content or null if there isn't any
/// </returns>
public Task<T?> getQuestion(string content);
/// <summary>
/// modified a question with an id
/// </summary>
/// <param name="id">the id of the question</param>
/// <param name="question">an question that contains all modified properties</param>
/// <returns>
/// the question modified that corresponde
/// to the id or null if there isn't any
/// </returns>
public Task<T?> updateQuestion(int id, T question);
/// <summary>
/// increase nbFalls of a question by 1
/// (and change the difficulty of the question)
/// </summary>
/// <param name="id">the id of the question</param>
/// <returns>
/// the question modified that corresponde
/// to the id or null if there isn't any
/// </returns>
public Task<T?> updateQuestionNbFalls(int id);
/// <summary>
/// add some questions
/// </summary>
/// <param name="questions">a set of questions to add</param>
/// <returns>questions added</returns>
public Task<IEnumerable<T>> addQuestions(IEnumerable<T> questions);
/// <summary>
/// get a part of all questions for a given chapter and a given difficulty
/// </summary>
/// <param name="idChapter">the id of the chapter</param>
/// <param name="difficulty">the difficulty</param>
/// <param name="nb">the actual page</param>
/// <param name="count">number of question in a page</param>
/// <param name="orderCriteria">the order criteria</param>
/// <returns>
/// a set of the number of page and
/// all questions in the database for
/// the page nb (or null if the page
/// does not exist (<=> (nb-1)*count outside
/// boundaries (0, getNbElement()-1)))
/// or null if the chapter does not exist
/// or the difficulty is not between 1 and 3
/// </returns>
public Task<(int nbPages, IEnumerable<T>? questions)?> getQuestionsByChapterAndDifficulty(int idChapter, int difficulty, int nb, int count, QuestionOrderCriteria orderCriteria = QuestionOrderCriteria.ById);
}
}