mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 10:43:13 +00:00
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
|
|
using Data.SeaHavenIndustries;
|
||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using SeaHaven.DataServices.Interfaces;
|
||
|
|
|
||
|
|
namespace SeaHaven.DataServices.Implementation
|
||
|
|
{
|
||
|
|
public class DashboardDataService : IDashboardDataService
|
||
|
|
{
|
||
|
|
private readonly ApplicationDbContext _context;
|
||
|
|
|
||
|
|
public DashboardDataService(ApplicationDbContext context)
|
||
|
|
{
|
||
|
|
_context = context;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<DashboardCounts> GetWorkOrderCountsAsync(CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
var query = _context.workOrders.Where(w => w.istemplate != true);
|
||
|
|
|
||
|
|
var total = await query.CountAsync(cancellationToken);
|
||
|
|
var open = await query.CountAsync(w => w.Status == "Open" || w.Status == "In Progress" || w.Status == "On Hold", cancellationToken);
|
||
|
|
var notDispatched = await query.CountAsync(w => (w.Status == "Open") && (w.AssignTo == null || w.AssignTo == ""), cancellationToken);
|
||
|
|
var completed = await query.CountAsync(w => w.Status == "Done", cancellationToken);
|
||
|
|
|
||
|
|
return new DashboardCounts
|
||
|
|
{
|
||
|
|
Total = total,
|
||
|
|
Open = open,
|
||
|
|
NotDispatched = notDispatched,
|
||
|
|
Completed = completed
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|