Reorg codice prod
This commit is contained in:
@@ -73,7 +73,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// procedo SOLO SE NON è stato prodotto (se è stato prodotto --> NON permetto la cancellazione ed esco con false...)
|
||||
// procedo SOLO SE NON è stato prodotto (se è stato prodotto --> NON permetto la
|
||||
// cancellazione ed esco con false...)
|
||||
if (!currProd.IsProduced)
|
||||
{
|
||||
// sel dei proj da aggiornare...
|
||||
@@ -145,7 +146,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return done;
|
||||
}
|
||||
@@ -481,50 +481,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x Description
|
||||
/// </summary>
|
||||
/// <param name="ProdId"></param>
|
||||
/// <param name="Description"></param>
|
||||
/// <returns></returns>
|
||||
public bool UpdateDescription(int ProdId, string Description)
|
||||
{
|
||||
bool fatto = false;
|
||||
// cerco specifico Prod
|
||||
ProdModel currData = new ProdModel();
|
||||
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
|
||||
{
|
||||
currData = localDbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.SingleOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// aggiorno valore descrizione
|
||||
currData.Description = Description;
|
||||
|
||||
// Commit changes
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string errMessage = $"EXCEPTION on Prod.UpdateDescription:{Environment.NewLine}{exc}";
|
||||
Console.WriteLine(errMessage);
|
||||
Log.Error(errMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errMessage = $"ERROR on Prod.UpdateDescription: req item was not found | ProdId {ProdId} | Description {Description}";
|
||||
Console.WriteLine(errMessage);
|
||||
Log.Error(errMessage);
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x campo IsArchived
|
||||
/// </summary>
|
||||
@@ -579,13 +535,14 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x campo IsProduced
|
||||
/// Update record su DB x Description
|
||||
/// </summary>
|
||||
/// <param name="ProdId"></param>
|
||||
/// <param name="IsProduced"></param>
|
||||
/// <param name="Description"></param>
|
||||
/// <returns></returns>
|
||||
protected bool UpdateProduced(int ProdId, bool IsProduced)
|
||||
public bool UpdateDescription(int ProdId, string Description)
|
||||
{
|
||||
bool fatto = false;
|
||||
// cerco specifico Prod
|
||||
@@ -601,21 +558,21 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
try
|
||||
{
|
||||
// aggiorno valore descrizione
|
||||
currData.IsProduced = IsProduced;
|
||||
currData.Description = Description;
|
||||
|
||||
// Commit changes
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string errMessage = $"EXCEPTION on Prod.UpdateProduced:{Environment.NewLine}{exc}";
|
||||
string errMessage = $"EXCEPTION on Prod.UpdateDescription:{Environment.NewLine}{exc}";
|
||||
Console.WriteLine(errMessage);
|
||||
Log.Error(errMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errMessage = $"ERROR on Prod.UpdateProduced: req item was not found | ProdId {ProdId} | IsProduced {IsProduced}";
|
||||
string errMessage = $"ERROR on Prod.UpdateDescription: req item was not found | ProdId {ProdId} | Description {Description}";
|
||||
Console.WriteLine(errMessage);
|
||||
Log.Error(errMessage);
|
||||
}
|
||||
@@ -954,31 +911,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Get LAST paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
protected List<ProdModel> GetLastDbModelDesc(int numRecord)
|
||||
{
|
||||
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
|
||||
{
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = localDbCtx.ProdList.Count();
|
||||
}
|
||||
// retrieve
|
||||
return localDbCtx
|
||||
.ProdList
|
||||
.OrderByDescending(x => x.ProdId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected List<int> ProjIdByProd(int ProdId)
|
||||
{
|
||||
var ProjCtr = new ProjController();
|
||||
@@ -996,5 +928,54 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x campo IsProduced lasciato private se servisse in futuro x ora NON
|
||||
/// esposto e fatto implicitamente in StatusMapController.StartProd
|
||||
/// </summary>
|
||||
/// <param name="ProdId"></param>
|
||||
/// <param name="IsProduced"></param>
|
||||
/// <returns></returns>
|
||||
private bool UpdateProduced(int ProdId, bool IsProduced)
|
||||
{
|
||||
bool fatto = false;
|
||||
// cerco specifico Prod
|
||||
ProdModel currData = new ProdModel();
|
||||
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
|
||||
{
|
||||
currData = localDbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.SingleOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// aggiorno valore descrizione
|
||||
currData.IsProduced = IsProduced;
|
||||
|
||||
// Commit changes
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string errMessage = $"EXCEPTION on Prod.UpdateProduced:{Environment.NewLine}{exc}";
|
||||
Console.WriteLine(errMessage);
|
||||
Log.Error(errMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errMessage = $"ERROR on Prod.UpdateProduced: req item was not found | ProdId {ProdId} | IsProduced {IsProduced}";
|
||||
Console.WriteLine(errMessage);
|
||||
Log.Error(errMessage);
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user