get all accounts endpoint added

This commit is contained in:
2024-11-06 16:29:24 +01:00
Unverified
parent d6fda7dbb8
commit 57fd4ba7a1
9 changed files with 113 additions and 1 deletions

View File

@@ -94,6 +94,11 @@ public class AccountsController(IAccountsControllerService accountsControllerSer
#region Info
[HttpGet]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<AccountResponse>), StatusCodes.Status200OK)]
public async Task<ActionResult> GetAccounts(AccountQueryParameters query) => await accountsControllerService.GetAccounts(query);
[HttpGet("{id}")]
[AllowAnonymous]
[ProducesResponseType(typeof(AccountResponse), StatusCodes.Status200OK)]

View File

@@ -238,6 +238,14 @@ public class AccountsControllerService(
#region Info
public async Task<RequestResult> GetAccounts(AccountQueryParameters query)
{
IEnumerable<Account> accounts = await database.Accounts.ToListAsync();
IEnumerable<AccountResponse> accountsData = accounts.Select(x => new AccountResponse(x));
accountsData = query.PrepareData(accountsData);
return RequestResult.Ok(accountsData);
}
public async Task<RequestResult> GetAccount(long id)
{
Account? account = await database.Accounts.FirstOrDefaultAsync(x => x.Id == id);

View File

@@ -19,6 +19,7 @@ public interface IAccountsControllerService
Task<RequestResult> GetAccountProfileBackground(long id);
Task<RequestResult> PutAccountProfileBackground(AccountProfileBackgroundRequest data);
Task<RequestResult> DeleteAccountProfileBackground();
Task<RequestResult> GetAccounts(AccountQueryParameters query);
Task<RequestResult> GetAccount(long id);
Task<RequestResult> PutAccountProfileInfo(AccountProfileInfoRequest data);
Task<RequestResult> PatchAccountUsername(AccountUsernameRequest data);