From a98f15d10337fa8829231a336b52b56621a81e85 Mon Sep 17 00:00:00 2001 From: maxime Date: Sun, 17 Mar 2024 10:55:07 +0100 Subject: [PATCH] add documentation on services --- Services/ITacticService.cs | 96 ++++++++++++++++++++++++++++++++------ Services/ITeamService.cs | 60 +++++++++++++++++++----- Services/UserService.cs | 38 +++++++++++++-- 3 files changed, 165 insertions(+), 29 deletions(-) diff --git a/Services/ITacticService.cs b/Services/ITacticService.cs index 98d68e7..9f443ac 100644 --- a/Services/ITacticService.cs +++ b/Services/ITacticService.cs @@ -2,25 +2,95 @@ using Model; namespace Services; +/// +/// Represents a service interface for managing tactics. +/// public interface ITacticService { + /// + /// Retrieves a list of tactics owned by the specified user. + /// + /// The ID of the user. + /// A task that represents the asynchronous operation. The task result contains a list of tactics. + Task> ListTacticsOf(int userId); - public Task> ListTacticsOf(int userId); - - public Task HasAnyRights(int userId, int tacticId); + /// + /// Checks if the user has any rights to access the specified tactic. + /// + /// The ID of the user. + /// The ID of the tactic. + /// A task that represents the asynchronous operation. The task result contains a boolean indicating whether the user has rights. + Task HasAnyRights(int userId, int tacticId); + /// + /// Adds a new tactic for the specified user. + /// + /// The ID of the user. + /// The name of the tactic. + /// The type of court. + /// A task that represents the asynchronous operation. The task result contains the ID of the newly added tactic. + Task AddTactic(int userId, string name, CourtType courtType); - public Task AddTactic(int userId, string name, CourtType courtType); + /// + /// Updates the name of the specified tactic. + /// + /// The ID of the tactic. + /// The new name of the tactic. + /// A task that represents the asynchronous operation. The task result contains a boolean indicating whether the update was successful. + Task UpdateName(int tacticId, string name); - public Task UpdateName(int tacticId, string name); - public Task SetTacticStepContent(int tacticId, int stepId, string json); - public Task GetTacticStepContent(int tacticId, int stepId); + /// + /// Sets the content of a tactic step. + /// + /// The ID of the tactic. + /// The ID of the step. + /// The JSON content to set. + /// A task that represents the asynchronous operation. The task result contains a boolean indicating whether the operation was successful. + Task SetTacticStepContent(int tacticId, int stepId, string json); - public Task GetTactic(int tacticId); + /// + /// Retrieves the content of a tactic step. + /// + /// The ID of the tactic. + /// The ID of the step. + /// A task that represents the asynchronous operation. The task result contains the JSON content of the step. + Task GetTacticStepContent(int tacticId, int stepId); - public Task GetRootStep(int tacticId); - - public Task> ListUserTactics(int userId); - public Task AddTacticStep(int tacticId, int parentStepId, string initialJson); - public Task RemoveTacticStep(int tacticId, int stepId); + /// + /// Retrieves the root step of the specified tactic. + /// + /// The ID of the tactic. + /// A task that represents the asynchronous operation. The task result contains the root step of the tactic. + Task GetRootStep(int tacticId); + + /// + /// Retrieves the tactic with the specified ID. + /// + /// The ID of the tactic. + /// A task that represents the asynchronous operation. The task result contains the tactic. + Task GetTactic(int tacticId); + + /// + /// Retrieves a list of tactics owned by the specified user. + /// + /// The ID of the user. + /// A task that represents the asynchronous operation. The task result contains a list of tactics. + Task> ListUserTactics(int userId); + + /// + /// Adds a new step to the specified tactic. + /// + /// The ID of the tactic. + /// The ID of the parent step. + /// The initial JSON content of the step. + /// A task that represents the asynchronous operation. The task result contains the ID of the newly added step. + Task AddTacticStep(int tacticId, int parentStepId, string initialJson); + + /// + /// Removes the specified step from the tactic, along with its child steps if any. + /// + /// The ID of the tactic. + /// The ID of the step to remove. + /// A task that represents the asynchronous operation. The task result contains a boolean indicating whether the removal was successful. + Task RemoveTacticStep(int tacticId, int stepId); } \ No newline at end of file diff --git a/Services/ITeamService.cs b/Services/ITeamService.cs index 1853f76..d806fb6 100644 --- a/Services/ITeamService.cs +++ b/Services/ITeamService.cs @@ -2,26 +2,61 @@ using Model; namespace Services; +/// +/// Represents a service for managing teams. +/// public interface ITeamService { - public Task> ListTeamsOf(int userId); + /// + /// Lists all teams associated with the specified . + /// + Task> ListTeamsOf(int userId); + /// + /// Lists a range of teams. + /// + Task> ListTeams(int start, int count); - public Task> ListTeams(int start, int count); - public Task CountTotalTeams(); + /// + /// Retrieves the total count of teams. + /// + Task CountTotalTeams(); - public Task AddTeam(string name, string picture, string firstColor, string secondColor); - public Task RemoveTeams(params int[] teams); + /// + /// Adds a new team. + /// + Task AddTeam(string name, string picture, string firstColor, string secondColor); - public Task> GetMembersOf(int teamId); + /// + /// Removes one or more teams. + /// + Task RemoveTeams(params int[] teams); - public Task AddMember(int teamId, int userId, MemberRole role); - - public Task UpdateMember(Member member); + /// + /// Updates an existing team. + /// + Task UpdateTeam(Team team); - public Task RemoveMember(int teamId, int userId); + /// + /// Retrieves the members of the specified team. + /// + Task> GetMembersOf(int teamId); + + /// + /// Adds a new member to the team. + /// + Task AddMember(int teamId, int userId, MemberRole role); + + /// + /// Updates the role of a member within the team. + /// + Task UpdateMember(Member member); + + /// + /// Removes a member from the team. + /// + Task RemoveMember(int teamId, int userId); - public Task UpdateTeam(Team team); enum TeamAccessibility { @@ -29,10 +64,12 @@ public interface ITeamService * The Team or the user is not found */ NotFound, + /** * Accessibility not granted */ Unauthorized, + /** * Accessibility granted */ @@ -45,5 +82,4 @@ public interface ITeamService * given team. */ public Task EnsureAccessibility(int userId, int teamId, MemberRole role); - } \ No newline at end of file diff --git a/Services/UserService.cs b/Services/UserService.cs index 3639347..ca3de87 100644 --- a/Services/UserService.cs +++ b/Services/UserService.cs @@ -2,23 +2,53 @@ namespace Services; +/// +/// Represents a service for managing users. +/// public interface IUserService { - + /// + /// Retrieves the count of users whose names contain the specified needle. + /// Task UsersCount(string nameNeedle); + + /// + /// Retrieves the total count of users. + /// Task UsersCount(); - + + /// + /// Lists a range of users, optionally filtering by name. + /// Task> ListUsers(int start, int count, string? nameNeedle = null); + /// + /// Retrieves the user with the specified ID. + /// Task GetUser(int id); + + /// + /// Retrieves the user with the specified email. + /// Task GetUser(string email); + /// + /// Creates a new user. + /// Task CreateUser(string username, string email, string password, string profilePicture, bool isAdmin); + /// + /// Removes one or more users. + /// Task RemoveUsers(params int[] identifiers); + /// + /// Updates an existing user. + /// Task UpdateUser(User user); - - public Task Authorize(string email, string password); + /// + /// Authorizes a user with the specified email and password. + /// + Task Authorize(string email, string password); } \ No newline at end of file