26 lines
890 B
C#
26 lines
890 B
C#
namespace Drab.Logic.Services;
|
|
|
|
public class LocalOrderStore(IServiceScopeFactory serviceScopeFactory) : ILocalOrderStore
|
|
{
|
|
public async Task<List<OrderDb>> GetAll()
|
|
{
|
|
using var scope = serviceScopeFactory.CreateScope();
|
|
await using var dbContext = scope.ServiceProvider.GetService<LocalDbContext>();
|
|
var fromDate = DateTime.UtcNow.AddDays(-30);
|
|
|
|
var orders = dbContext.Orders
|
|
.Where(x => x.Created >= fromDate)
|
|
.OrderByDescending(x => x.Created)
|
|
.ToList();
|
|
return orders;
|
|
}
|
|
|
|
public async Task<DokDto> GetOrderById(long dokId)
|
|
{
|
|
using var scope = serviceScopeFactory.CreateScope();
|
|
await using var dbContext = scope.ServiceProvider.GetService<LocalDbContext>();
|
|
var order = dbContext.Orders.FirstOrDefault(x => x.DokId == dokId);
|
|
|
|
return new DokDto();
|
|
}
|
|
} |