New Angular based web version #1
@@ -51,13 +51,16 @@ public static class GetConsumptions
|
||||
ApplicationDbContext dbContext,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
List<Consumption> consumptions = await dbContext.Consumptions
|
||||
Dictionary<CarId, List<Consumption>> consumptionsByCar = await dbContext.Consumptions
|
||||
.OrderByDescending(x => x.DateTime)
|
||||
.Include(x => x.Car)
|
||||
.ToListAsync(cancellationToken);
|
||||
.GroupBy(x => x.CarId)
|
||||
.ToDictionaryAsync(x => x.Key, x => x.ToList(), cancellationToken);
|
||||
|
||||
List<ResponseDto> responses = [];
|
||||
|
||||
foreach (var consumptions in consumptionsByCar.Select(x => x.Value))
|
||||
{
|
||||
for (int i = 0; i < consumptions.Count; i++)
|
||||
{
|
||||
Consumption consumption = consumptions[i];
|
||||
@@ -80,6 +83,7 @@ public static class GetConsumptions
|
||||
CarDto.FromCar(consumption.Car),
|
||||
literPer100Km));
|
||||
}
|
||||
}
|
||||
|
||||
ApiResponse apiResponse = new() { Consumptions = responses };
|
||||
return TypedResults.Ok(apiResponse);
|
||||
|
||||
Reference in New Issue
Block a user