Fix limite sync a 1 anno

This commit is contained in:
Samuele Locatelli
2024-07-17 11:20:28 +02:00
parent 33c55dfc62
commit 130b71aaf7
@@ -121,21 +121,26 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <returns></returns>
public MagmanSyncModel GetLastBySync(string SyncType)
{
// record default al 1900..
// record default a 1 anno fa...
DateTime dtLim = DateTime.Today.AddYears(-1);
MagmanSyncModel dbResult = new MagmanSyncModel()
{
CloudId = 0,
SyncType = SyncType,
DtReq = DateTime.MinValue,
DtReq = dtLim,
Payload = ""
};
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
dbResult = localDbCtx
var rawRes = localDbCtx
.SyncList
.Where(x => (!string.IsNullOrEmpty(SyncType) && x.SyncType == SyncType))
.OrderByDescending(x => x.DtReq)
.FirstOrDefault();
if (rawRes != null)
{
dbResult = rawRes;
}
}
return dbResult;
}