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/IChapterManager.cs

97 lines
3.3 KiB

using OrderCriterias;
using System;
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 chapters
/// /!\ all methods returns a task
/// </summary>
/// <typeparam name="T">a DTO, Entity or Model chapter</typeparam>
public interface IChapterManager<T>
{
/// <summary>
/// get the number of chapters
/// </summary>
/// <returns>the number of chapters</returns>
public int getNbChapters();
/// <summary>
/// add a chapter
/// </summary>
/// <param name="chapter">chapter to add</param>
/// <returns>
/// the chapter added or the chapter that correspond
/// to it and that is already in the database
/// </returns>
Task<T> addChapter(T chapter);
/// <summary>
/// remove a chapter
/// </summary>
/// <param name="chapter">the chapter to remove</param>
/// <returns>
/// the chapter removed or null if
/// the chapter does not exist
/// </returns>
Task<T?> removeChapter(T chapter);
/// <summary>
/// remove a chapter
/// </summary>
/// <param name="id">the identifier of the chapter to remove</param>
/// <returns>
/// the chapter removed or null if
/// the chapter does not exist
/// </returns>
Task<T?> removeChapter(int id);
/// <summary>
/// get a chapter
/// </summary>
/// <param name="id">the identifier of the chapter</param>
/// <returns>
/// the chapter that correspond
/// to the id or null if the
/// chapter does not exist
/// </returns>
Task<T?> getChapter(int id);
/// <summary>
/// get a chapter
/// </summary>
/// <param name="name">the name of the chapter</param>
/// <returns>
/// the chapter that correspond
/// to the name or null if the
/// chapter does not exist
/// </returns>
Task<T?> getChapter(string name);
/// <summary>
/// get a part of all chapters
/// </summary>
/// <param name="nb">the actual page</param>
/// <param name="count">number of chapters in a page</param>
/// <param name="orderCriteria">the order criteria</param>
/// <returns>
/// a set of the number of page and
/// all chapters in the database for
/// the page nb (or null if the page
/// does not exist (<=> (nb-1)*count outside
/// boundaries (0, getNbElement()-1)))
/// </returns>
Task<(int nbPages, IEnumerable<T>? chapters)> getChapters(int nb, int count, ChapterOrderCriteria orderCriteria = ChapterOrderCriteria.ById);
/// <summary>
/// update a chapter
/// </summary>
/// <param name="id">the id of the chapter to update</param>
/// <param name="newName">the new name of the chapter</param>
/// <returns>
/// the chapter modified or null if
/// the id does not refer a chapter
/// </returns>
Task<T?> updateChapter(int id, string newName);
}
}