55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using DeluxeBackend.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using DeluxeBackend.Models;
|
|
|
|
namespace DeluxeBackend.Controllers.Accounts
|
|
{
|
|
[Route("Accounts/account/bulk")]
|
|
[ApiController]
|
|
public class BulkController : ControllerBase
|
|
{
|
|
|
|
private readonly ILiteDbService db;
|
|
private readonly bool setup = false;
|
|
|
|
public BulkController(ILiteDbService _db, IJwtService _jwtService)
|
|
{
|
|
db = _db;
|
|
|
|
if (!setup)
|
|
{
|
|
if (db.Accounts.FindById(1) == null)
|
|
{
|
|
Account account = new()
|
|
{
|
|
Username = "Coach",
|
|
DisplayName = "Coach",
|
|
Birthday = DateOnly.MinValue,
|
|
ImageName= "DefaultProfileImage"
|
|
};
|
|
db.Accounts.Insert(account);
|
|
}
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> Bulk([FromQuery(Name ="id")] List<long> accountIds)
|
|
{
|
|
var accounts = db.Accounts.Find(x => accountIds.Contains(x.Id));
|
|
var accountDictionaries = accounts.Select(a => a.ToDictionary()).ToList();
|
|
|
|
return Ok(accountDictionaries);
|
|
}
|
|
|
|
[HttpGet("all_db")]
|
|
public async Task<IActionResult> all()
|
|
{
|
|
var accounts = db.Accounts.FindAll();
|
|
|
|
return Ok(accounts.ToList());
|
|
}
|
|
}
|
|
}
|