Add remaining project files
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user