Update doc and todo (#4)

* Updade doc

* Updade doc
This commit is contained in:
Oda
2024-07-20 21:33:50 +07:00
committed by GitHub
parent a43e560d3a
commit 743d04e6c5
12 changed files with 483 additions and 71 deletions

View File

@@ -5,11 +5,20 @@ using Microsoft.AspNetCore.Mvc;
namespace Managing.Api.Controllers
{
/// <summary>
/// Provides endpoints for account management operations such as creating, retrieving, and deleting accounts.
/// Requires authorization for access.
/// </summary>
[Authorize]
public class AccountController : BaseController
{
private readonly IAccountService _AccountService;
/// <summary>
/// Initializes a new instance of the <see cref="AccountController"/> class.
/// </summary>
/// <param name="AccountService">Service for account-related operations.</param>
/// <param name="userService">Service for user-related operations.</param>
public AccountController(
IAccountService AccountService,
IUserService userService)
@@ -18,6 +27,11 @@ namespace Managing.Api.Controllers
_AccountService = AccountService;
}
/// <summary>
/// Creates a new account for the authenticated user.
/// </summary>
/// <param name="Account">The account details to create.</param>
/// <returns>The created account details.</returns>
[HttpPost]
public async Task<ActionResult<Account>> PostAccount(Account Account)
{
@@ -25,6 +39,10 @@ namespace Managing.Api.Controllers
return Ok(await _AccountService.CreateAccount(user, Account));
}
/// <summary>
/// Retrieves all accounts associated with the authenticated user.
/// </summary>
/// <returns>A list of accounts.</returns>
[HttpGet]
[Route("accounts")]
public async Task<ActionResult<IEnumerable<Account>>> GetAccounts()
@@ -33,6 +51,10 @@ namespace Managing.Api.Controllers
return Ok(_AccountService.GetAccountsByUser(user, true));
}
/// <summary>
/// Retrieves the balances of all accounts associated with the authenticated user.
/// </summary>
/// <returns>A list of accounts with their balances.</returns>
[HttpGet]
[Route("balances")]
public async Task<ActionResult<IEnumerable<Account>>> GetAccountsBalances()
@@ -41,6 +63,11 @@ namespace Managing.Api.Controllers
return Ok(_AccountService.GetAccountsBalancesByUser(user));
}
/// <summary>
/// Retrieves a specific account by name for the authenticated user.
/// </summary>
/// <param name="name">The name of the account to retrieve.</param>
/// <returns>The account details if found.</returns>
[HttpGet]
public async Task<ActionResult<Account>> GetAccount(string name)
{
@@ -48,6 +75,11 @@ namespace Managing.Api.Controllers
return Ok(await _AccountService.GetAccountByUser(user, name, true, true));
}
/// <summary>
/// Deletes a specific account by name for the authenticated user.
/// </summary>
/// <param name="name">The name of the account to delete.</param>
/// <returns>An ActionResult indicating the outcome of the operation.</returns>
[HttpDelete]
public ActionResult DeleteAccount(string name)
{
@@ -55,4 +87,4 @@ namespace Managing.Api.Controllers
return Ok(_AccountService.DeleteAccount(user, name));
}
}
}
}