Merge remote-tracking branch 'gitlab.seriate/develop' into feature/total_rebuild
This commit is contained in:
@@ -26,6 +26,17 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Helper conversione modelli
|
||||
/// </summary>
|
||||
/// <param name="currProj"></param>
|
||||
/// <returns></returns>
|
||||
protected Core.ProjFileM coreConv(ProjModel currProj)
|
||||
{
|
||||
Core.ProjFileM answ = Core.ProjFileM.CreateProjFileM(currProj.ProjId, ProdIdByProdDbId(currProj.ProdDbId), currProj.DtCreated, currProj.DtExported, currProj.ListName, currProj.BTLFileName);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get LAST paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
@@ -112,12 +123,13 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjDbId(int ProjDbId)
|
||||
public Core.ProjFileM FindByProjDbId(int ProjDbId)
|
||||
{
|
||||
return dbCtx
|
||||
Core.ProjFileM answ = coreConv(dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
.SingleOrDefault());
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,57 +139,13 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjId(int ProjId)
|
||||
{
|
||||
return dbCtx
|
||||
.ProjList
|
||||
var answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Get paginated data from DB (ASC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProjDbIdStart"></param>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetPaginatedAsc(int ProjDbIdStart, int numRecord)
|
||||
{
|
||||
int numEnd = ProjDbIdStart - numRecord;
|
||||
// check numEnd
|
||||
if (numEnd < 0)
|
||||
numEnd = 0;
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId <= ProjDbIdStart)
|
||||
.OrderBy(x => x.ProjDbId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="PartDbIdStart"></param>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetPaginatedDesc(int PartDbIdStart, int numRecord)
|
||||
{
|
||||
int numEnd = PartDbIdStart - numRecord;
|
||||
// check numEnd
|
||||
if (numEnd < 0)
|
||||
numEnd = 0;
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId <= PartDbIdStart)
|
||||
.OrderByDescending(x => x.ProjDbId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get filtered data by ProdId (ASC ordered)
|
||||
/// </summary>
|
||||
@@ -185,6 +153,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdAsc(int ProdId)
|
||||
{
|
||||
List<ProjModel> answ = new List<ProjModel>();
|
||||
int ProdDbId = 0;
|
||||
try
|
||||
{
|
||||
@@ -202,11 +171,12 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
Console.WriteLine($"EXCEPTION on GetByProdAsc: {exc}");
|
||||
}
|
||||
// retrieve
|
||||
return dbCtx
|
||||
answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderBy(x => x.ProdDbId)
|
||||
.ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -214,8 +184,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdDesc(int ProdId)
|
||||
public List<Core.ProjFileM> GetByProdDesc(int ProdId)
|
||||
{
|
||||
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
|
||||
int ProdDbId = 0;
|
||||
try
|
||||
{
|
||||
@@ -233,11 +204,14 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
Console.WriteLine($"EXCEPTION on GetByProdAsc: {exc}");
|
||||
}
|
||||
// retrieve
|
||||
return dbCtx
|
||||
var dbRes = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderByDescending(x => x.ProdDbId)
|
||||
.ToList();
|
||||
// conversione
|
||||
answ = dbRes.Select(x => coreConv(x)).ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -247,14 +221,22 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// <returns></returns>
|
||||
public List<Core.ProjFileM> GetLastDesc(int numRecord)
|
||||
{
|
||||
List<Core.ProjFileM> result = new List<Core.ProjFileM>();
|
||||
|
||||
var dbResult = GetLastDbModelDesc(numRecord);
|
||||
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
|
||||
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
}
|
||||
// retrieve
|
||||
var dbRes = dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
// conversione
|
||||
result = dbResult.Select(x => Core.ProjFileM.CreateProjFileM(x.ProjId, ProdIdByProdDbId(x.ProdDbId), x.DtCreated, x.DtExported, x.ListName, x.BTLFileName)).ToList();
|
||||
|
||||
return result;
|
||||
answ = dbRes.Select(x => coreConv(x)).ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -286,7 +268,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
// creo nuovo...
|
||||
var newRec = dbCtx
|
||||
.ProjList
|
||||
.Add(new ProjModel() { ProjId = nextId, BTLFileName = "", Locked = true, DtCreated = DateTime.Now });
|
||||
.Add(new ProjModel() { ProjId = nextId, BTLFileName = "", IsNew = true, Locked = true, DtCreated = DateTime.Now });
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
@@ -300,7 +282,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// <param name="ProjId">ProjID</param>
|
||||
/// <param name="Locked">Stato Lock da impostare</param>
|
||||
/// <returns></returns>
|
||||
public ProjModel LockByProjId(int ProjId, bool Locked)
|
||||
public Core.ProjFileM LockByProjId(int ProjId, bool Locked)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
@@ -319,7 +301,27 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return currProj;
|
||||
return coreConv(currProj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reimposta come NEW
|
||||
/// </summary>
|
||||
/// <param name="ProjId">ProjID</param>
|
||||
/// <param name="Locked">Stato Lock da impostare</param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM ResetNew(int ProjId)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// aggiorno stato
|
||||
currProj.IsNew = true;
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return coreConv(currProj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -397,7 +399,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
/// <param name="ListName"></param>
|
||||
/// <param name="DtExported"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel UpdateInfo(int ProjId, string BTLFileName, string ListName, DateTime DtExported)
|
||||
public Core.ProjFileM UpdateInfo(int ProjId, string BTLFileName, string ListName, DateTime DtExported)
|
||||
{
|
||||
var currData = FindByProjId(ProjId);
|
||||
// aggiorno valore BTL
|
||||
@@ -408,7 +410,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return currData;
|
||||
return coreConv(currData);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
Reference in New Issue
Block a user