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.
90 lines
3.8 KiB
90 lines
3.8 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 administrators
|
|
/// /!\ all methods returns a task
|
|
/// </summary>
|
|
/// <typeparam name="T">a DTO, Entity or Model administrator</typeparam>
|
|
public interface IAdministratorManager<T>
|
|
{
|
|
/// <summary>
|
|
/// get the number of administrators
|
|
/// </summary>
|
|
/// <returns>the number of administrators</returns>
|
|
public int getNbAdmins();
|
|
/// <summary>
|
|
/// add an administrator
|
|
/// </summary>
|
|
/// <param name="admin">the administrator to add</param>
|
|
/// <returns>
|
|
/// the element that correspond to
|
|
/// the administrator added or the administrator equal to this
|
|
/// administrator if this administrator was already added
|
|
/// </returns>
|
|
public Task<T> addAdmin(T admin);
|
|
/// <summary>
|
|
/// remove an administrators
|
|
/// </summary>
|
|
/// <param name="admin">the administrator to remove</param>
|
|
/// <returns>the administrator removed or null if there isn't any</returns>
|
|
public Task<T?> removeAdmin(T admin);
|
|
/// <summary>
|
|
/// remove an administrator
|
|
/// </summary>
|
|
/// <param name="id">the id of the administrator to remove</param>
|
|
/// <returns>the administrator removed or null if there isn't any</returns>
|
|
public Task<T?> removeAdmin(int id);
|
|
/// <summary>
|
|
/// get a part of all administrators
|
|
/// </summary>
|
|
/// <param name="page">the actual page</param>
|
|
/// <param name="count">number of administrators in a page</param>
|
|
/// <param name="orderCriteria">the order criteria</param>
|
|
/// <returns>
|
|
/// a set of the number of page and
|
|
/// all administrators 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>? administrators)> getAdministrators(int page, int count, AdministratorOrderCriteria orderCriteria = AdministratorOrderCriteria.ById);
|
|
/// <summary>
|
|
/// get an administrator by his identifier
|
|
/// </summary>
|
|
/// <param name="id">the identifier of the administrator</param>
|
|
/// <returns>the administrator that corresponde or null if there isn't any</returns>
|
|
public Task<T?> getAdministrator(int id);
|
|
/// <summary>
|
|
/// get an administrator by his username
|
|
/// </summary>
|
|
/// <param name="username">the username of the administrator</param>
|
|
/// <returns>the administrator that corresponde or null if there isn't any</returns>
|
|
public Task<T?> getAdministratorByUsername(string username);
|
|
/// <summary>
|
|
/// set the password of an administrator
|
|
/// </summary>
|
|
/// <param name="username">the username of the administrator</param>
|
|
/// <param name="newHashedPassword">the hash of the new password</param>
|
|
/// <returns>
|
|
/// true if the password was sucessful change
|
|
/// false otherwise (no administrator with this username
|
|
/// </returns>
|
|
public Task<bool> setPassword(string username, string newHashedPassword);
|
|
/// <summary>
|
|
/// upadte an administrator
|
|
/// </summary>
|
|
/// <param name="id">the id of the administrator to update</param>
|
|
/// <param name="admin">the admin that contains all properties to modify</param>
|
|
/// <returns>the administrator updated or null if he don't exist</returns>
|
|
public Task<T?> updateAdministrator(int id, T admin);
|
|
}
|
|
}
|