Aggiunta metodi per la gestione del magazzino
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using NLog;
|
||||
@@ -24,48 +23,6 @@ namespace MP.Data.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Inventari CORRENTI (=aperti, senza data fine)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<InventorySessionModel> InventSessCurrList()
|
||||
{
|
||||
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => x.DtEnd == null)
|
||||
.Include(m=>m.AnagMagNav)
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Inventari tipo Azienda (TUTTI, chiusi e paerti) filtrati x data
|
||||
/// </summary>
|
||||
/// <param name="FromDate"></param>
|
||||
/// <param name="ToDate"></param>
|
||||
/// <returns></returns>
|
||||
public List<InventorySessionModel> InventSessHistList(DateTime FromDate, DateTime ToDate)
|
||||
{
|
||||
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => x.DtStart >= FromDate && x.DtStart <= ToDate && x.DtEnd != null)
|
||||
.Include(m=>m.AnagMagNav)
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_configuration = null;
|
||||
@@ -90,23 +47,6 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco Magazzini
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagMagModel> ElencoMagazzini()
|
||||
{
|
||||
List<AnagMagModel> dbResult = new List<AnagMagModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbAnagMag
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MagID)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco operatori
|
||||
@@ -140,11 +80,31 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#region gestione magazzini
|
||||
|
||||
/// <summary>
|
||||
/// insert di un record sessione
|
||||
/// Elenco Magazzini
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> InsertNewSessione(InventorySessionModel newRec)
|
||||
public List<AnagMagModel> ElencoMagazzini()
|
||||
{
|
||||
List<AnagMagModel> dbResult = new List<AnagMagModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbAnagMag
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MagID)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// insert di un record magazzino
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> InsertNewMag(AnagMagModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
@@ -152,18 +112,48 @@ namespace MP.Data.Controllers
|
||||
try
|
||||
{
|
||||
dbCtx
|
||||
.DbInveSess
|
||||
.DbAnagMag
|
||||
.Add(newRec);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante InsertNewSessione{Environment.NewLine}{exc}");
|
||||
Log.Error($"Eccezione durante InsertNewMag{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete magazzino
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeleteMag(AnagMagModel record)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
dbCtx
|
||||
.DbAnagMag
|
||||
.Remove(record);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante deleteMag{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion gestione magazzini
|
||||
|
||||
#region gestione sessione
|
||||
|
||||
/// <summary>
|
||||
/// delete sessione
|
||||
/// </summary>
|
||||
@@ -188,6 +178,76 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// insert di un record sessione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> InsertNewSessione(InventorySessionModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
dbCtx
|
||||
.DbInveSess
|
||||
.Add(newRec);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante InsertNewSessione{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Inventari tipo Azienda (TUTTI, chiusi e paerti) filtrati x data
|
||||
/// </summary>
|
||||
/// <param name="FromDate"></param>
|
||||
/// <param name="ToDate"></param>
|
||||
/// <returns></returns>
|
||||
public List<InventorySessionModel> InventSessHistList(DateTime FromDate, DateTime ToDate)
|
||||
{
|
||||
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => x.DtStart >= FromDate && x.DtStart <= ToDate && x.DtEnd != null)
|
||||
.Include(m => m.AnagMagNav)
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Inventari CORRENTI (=aperti, senza data fine)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<InventorySessionModel> InventSessCurrList()
|
||||
{
|
||||
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => x.DtEnd == null)
|
||||
.Include(m => m.AnagMagNav)
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion gestione sessione
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
Reference in New Issue
Block a user