mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 13:00:55 +00:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
//using CartriX.Shared.Classes;
|
|
//using CartriX.Shared.Models;
|
|
//using Microsoft.EntityFrameworkCore;
|
|
|
|
//namespace CartriX.Api.Interfaces
|
|
//{
|
|
// public class ReportService : IReportService
|
|
// {
|
|
// private readonly AppDbContext _context;
|
|
// public ReportService(AppDbContext context)
|
|
// {
|
|
// _context = context;
|
|
// }
|
|
// public async Task<List<LogPrinter>> GetReportToDatePerCountPrinted()
|
|
// {
|
|
// DateTime dateToday = DateTime.Now.Date;
|
|
// DateTime dateWeekAgo = dateToday.AddDays(-6);
|
|
|
|
// var dbResult = await _context.LogPrinters
|
|
// .Where(l => l.date.Date >= dateWeekAgo && l.date.Date <= dateToday)
|
|
// .GroupBy(l => l.date.Date)
|
|
// .Select(g => new LogPrinter
|
|
// {
|
|
// date = g.Key,
|
|
// countPrinted = g.Sum(l => l.countPrinted)
|
|
// })
|
|
// .ToListAsync();
|
|
|
|
// var allDays = Enumerable.Range(0, 7)
|
|
// .Select(i => dateWeekAgo.AddDays(i))
|
|
// .ToList();
|
|
|
|
// var result = allDays
|
|
// .Select(day => dbResult.FirstOrDefault(x => x.date == day) ?? new LogPrinter
|
|
// {
|
|
// date = day,
|
|
// countPrinted = 0
|
|
// })
|
|
// .ToList();
|
|
|
|
// return result;
|
|
// }
|
|
|
|
// }
|
|
//}
|