107 lines
3.4 KiB
C#
107 lines
3.4 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Core.DTO;
|
|
using MP.Data.DbModels.Sched;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Data.Controllers
|
|
{
|
|
public class MpSchedulerController : IDisposable
|
|
{
|
|
#region Public Constructors
|
|
|
|
public MpSchedulerController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
Log.Info("Avviata classe MpSchedulerController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
|
|
public async Task<Dictionary<string, List<EventDto>>> PlannerGetEvents()
|
|
{
|
|
Dictionary<string, List<EventDto>> result = new Dictionary<string, List<EventDto>>();
|
|
using (var dbCtx = new MP_SchedContext(_configuration))
|
|
{
|
|
var RawData = await dbCtx
|
|
.DbSetPromOut
|
|
//.AsNoTracking()
|
|
.OrderBy(x => x.IdxPromessa)
|
|
.ToListAsync();
|
|
|
|
DateTime oggi = DateTime.Today;
|
|
|
|
result = RawData
|
|
.GroupBy(p => p.IdxMacchina)
|
|
.ToDictionary(
|
|
g => g.Key,
|
|
g => g.Select(p => new EventDto
|
|
{
|
|
IdxEv = p.IdxPromessa,
|
|
Abbrev = p.CodPODL,
|
|
Titolo = p.CodPODL,
|
|
DtEnd = p.DueDate ?? oggi.AddMonths(2),
|
|
DtStart = (p.DueDate ?? oggi.AddMonths(2)).AddDays(-3)
|
|
}).ToList()
|
|
);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco PromesseIN
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<PromesseInModel> PromInGetAll()
|
|
{
|
|
List<PromesseInModel> dbResult = new List<PromesseInModel>();
|
|
using (var dbCtx = new MP_SchedContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbSetPromIn
|
|
//.AsNoTracking()
|
|
.OrderBy(x => x.IdxPromessa)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco PromesseIN
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<PromesseOutModel> ProOutGetAll()
|
|
{
|
|
List<PromesseOutModel> dbResult = new List<PromesseOutModel>();
|
|
using (var dbCtx = new MP_SchedContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbSetPromOut
|
|
//.AsNoTracking()
|
|
.OrderBy(x => x.IdxPromessa)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static IConfiguration _configuration;
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |