Files
mapo-core/MP.Data/Controllers/MpTabController.cs
T
Samuele Locatelli 4f8b46882c Aggiunta modelli ST
2023-10-04 08:55:06 +02:00

126 lines
4.0 KiB
C#

using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MP.Data.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MP.Data.Controllers
{
public class MpTabController : IDisposable
{
#region Public Constructors
public MpTabController(IConfiguration configuration)
{
_configuration = configuration;
Log.Info("Avviato MpTabController");
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Restituisce l'anagrafica eventi per intero
/// </summary>
/// <returns></returns>
public List<AnagEventiModel> AnagEventiGetAll()
{
List<AnagEventiModel> dbResult = new List<AnagEventiModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetAnagEventi
.AsNoTracking()
.ToList();
}
return dbResult;
}
/// <summary>
/// Elenco da tabella Config
/// </summary>
/// <returns></returns>
public List<ConfigModel> ConfigGetAll()
{
List<ConfigModel> dbResult = new List<ConfigModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetConfig
.AsNoTracking()
.OrderBy(x => x.Chiave)
.ToList();
}
return dbResult;
}
public void Dispose()
{
_configuration = null;
}
/// <summary>
/// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL
/// </summary>
/// <param name="codGruppo"></param>
/// <param name="idxODL"></param>
/// <returns></returns>
public List<ST_ActRow> STAR_byGrpOdl(string codGruppo, int idxODL)
{
List<ST_ActRow> dbResult = new List<ST_ActRow>();
using (var dbCtx = new MoonProContext(_configuration))
{
var CodGruppo = new SqlParameter("@CodGruppo", codGruppo);
var IdxODL = new SqlParameter("@IdxODL", idxODL);
dbResult = dbCtx
.DbSetStActRow
.FromSqlRaw("exec dbo.stp_ST_AR_getByGrpOdl @CodGruppo, @IdxODL", CodGruppo, IdxODL)
.AsNoTracking()
.AsEnumerable()
.ToList();
}
return dbResult;
}
/// <summary>
/// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL + label
/// </summary>
/// <param name="codGruppo"></param>
/// <param name="label"></param>
/// <param name="idxODL"></param>
/// <returns></returns>
public List<ST_ActRow> STAR_byGrpOdlLbl(string codGruppo, string label, int idxODL)
{
List<ST_ActRow> dbResult = new List<ST_ActRow>();
using (var dbCtx = new MoonProContext(_configuration))
{
var CodGruppo = new SqlParameter("@CodGruppo", codGruppo);
var Label = new SqlParameter("@Label", label);
var IdxODL = new SqlParameter("@IdxODL", idxODL);
dbResult = dbCtx
.DbSetStActRow
.FromSqlRaw("exec dbo.stp_ST_AR_getGrpOdlLabel @CodGruppo, @Label, @IdxODL", CodGruppo, Label, IdxODL)
.AsNoTracking()
.AsEnumerable()
.ToList();
}
return dbResult;
}
#endregion Public Methods
#region Private Fields
private static IConfiguration _configuration;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}