243 lines
7.7 KiB
C#
243 lines
7.7 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using NLog;
|
|
using StockMan.Data.DbModels;
|
|
|
|
namespace StockMan.Data.Controllers
|
|
{
|
|
public class StoManController : IDisposable
|
|
{
|
|
#region Public Constructors
|
|
|
|
public StoManController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
Log.Info("Avviata classe StoManController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Lista Permessi
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<PermessiModel> PermessiGetAll()
|
|
{
|
|
List<PermessiModel> dbResult = new List<PermessiModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetPermessi
|
|
.OrderBy(x => x.GRUPPO)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Contatori
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<CountersListModel> CountersGetAll()
|
|
{
|
|
List<CountersListModel> dbResult = new List<CountersListModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetCountersList
|
|
.OrderBy(x => x.Id)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
GC.Collect();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Famiglie Articoli
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ItemFamilyModel> ItemFamilyGetAll()
|
|
{
|
|
List<ItemFamilyModel> dbResult = new List<ItemFamilyModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetItemFamily
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Famiglie Articoli da ricerca
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ItemFamilyModel> ItemFamilyGetSearch(string searchVal)
|
|
{
|
|
List<ItemFamilyModel> dbResult = new List<ItemFamilyModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetItemFamily
|
|
.Where(x => x.Descr.Contains(searchVal))
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Item Flux (ALL!)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ItemFluxModel> ItemsFluxGetAll()
|
|
{
|
|
List<ItemFluxModel> dbResult = new List<ItemFluxModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetItemFlux
|
|
.OrderBy(x => x.DtMov)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Items
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ItemModel> ItemsGetAll()
|
|
{
|
|
List<ItemModel> dbResult = new List<ItemModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetItem
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Items da ricerca
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ItemModel> ItemsGetSearch(string searchVal)
|
|
{
|
|
List<ItemModel> dbResult = new List<ItemModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetItem
|
|
.Where(x => x.CodExt.Contains(searchVal) || x.Descr.Contains(searchVal) || x.DescrExt.Contains(searchVal))
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Item Stock (ALL!)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ItemStockModel> ItemsStockGetAll()
|
|
{
|
|
List<ItemStockModel> dbResult = new List<ItemStockModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetItemStock
|
|
.OrderBy(x => x.Id)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Locazioni
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<LocationModel> LocationGetAll()
|
|
{
|
|
List<LocationModel> dbResult = new List<LocationModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetLocation
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Tipi Locazioni
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<LocTypeModel> LocTypeGetAll()
|
|
{
|
|
List<LocTypeModel> dbResult = new List<LocTypeModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetLocType
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Tipi Movimenti
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<MovTypeModel> MovTypeGetAll()
|
|
{
|
|
List<MovTypeModel> dbResult = new List<MovTypeModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetMovType
|
|
.OrderBy(x => x.Descr)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista Operatori
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<OperatorModel> OperatorsGetAll()
|
|
{
|
|
List<OperatorModel> dbResult = new List<OperatorModel>();
|
|
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetOperator
|
|
.OrderBy(x => x.LastName)
|
|
.ThenBy(x => x.FirstName)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static IConfiguration _configuration = null!;
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |