236 lines
7.8 KiB
C#
236 lines
7.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.AppAuth.Models;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.AppAuth.Controllers
|
|
{
|
|
public class AppAuthController
|
|
{
|
|
#region Public Constructors
|
|
|
|
public AppAuthController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
|
|
Log.Info("Avviata classe AppAuthController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Elenco Record x Gruppi
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<AnagraficaGruppi> AnagGruppiFilt(string codTipo)
|
|
{
|
|
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
|
|
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetAnagraficaGruppi
|
|
.Where(x => x.TipoGruppo == codTipo)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Record x Gruppi
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<AnagraficaGruppi> AnagGruppiGetAll()
|
|
{
|
|
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
|
|
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetAnagraficaGruppi
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
public List<AnagraficaOperatori> AnagOpByGruppoGetFilt(string codGruppo, string searchVal)
|
|
{
|
|
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
|
|
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
if (!string.IsNullOrEmpty(searchVal))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetGruppi2Oper
|
|
.Where(x => x.CodGruppo == codGruppo || string.IsNullOrEmpty(codGruppo))
|
|
.Join(
|
|
localDbCtx.DbSetAnagOpr.Where(x => x.Cognome.Contains(searchVal) || x.Nome.Contains(searchVal)),
|
|
gruppo => gruppo.MatrOpr,
|
|
operatore => operatore.MatrOpr,
|
|
(gruppo, operatore) => operatore
|
|
)
|
|
.ToList();
|
|
}
|
|
else
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetGruppi2Oper
|
|
.Where(x => x.CodGruppo == codGruppo || string.IsNullOrEmpty(codGruppo))
|
|
.Join(
|
|
localDbCtx.DbSetAnagOpr,
|
|
gruppo => gruppo.MatrOpr,
|
|
operatore => operatore.MatrOpr,
|
|
(gruppo, operatore) => operatore
|
|
)
|
|
.ToList();
|
|
}
|
|
}
|
|
// ritorno
|
|
return dbResult;
|
|
}
|
|
|
|
public List<AnagraficaOperatori> AnagOpGetAll(string searchVal)
|
|
{
|
|
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
|
|
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
if (!string.IsNullOrEmpty(searchVal))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetAnagOpr
|
|
.Where(x => x.Cognome.Contains(searchVal) || x.Nome.Contains(searchVal))
|
|
.ToList();
|
|
}
|
|
else
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetAnagOpr
|
|
.ToList();
|
|
}
|
|
}
|
|
// ritorno
|
|
return dbResult;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Elenco completo permessi2funzione
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Permessi2FunzioneModel> Permessi2FunzioneGetAll()
|
|
{
|
|
List<Permessi2FunzioneModel> dbResult = new List<Permessi2FunzioneModel>();
|
|
using (AppAuthContext dbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbSetPermessi2Funzione
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco permessi2funzione filtrato x elenco funzioni
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Permessi2FunzioneModel> Permessi2FunzioneGetFilt(List<string> FunList)
|
|
{
|
|
List<Permessi2FunzioneModel> dbResult = new List<Permessi2FunzioneModel>();
|
|
using (AppAuthContext dbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbSetPermessi2Funzione
|
|
.Where(x => FunList.Contains(x.CodFunzione))
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco completo permessi
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<PermessiModel> PermessiGetAll()
|
|
{
|
|
List<PermessiModel> dbResult = new List<PermessiModel>();
|
|
using (AppAuthContext dbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbSetPermessi
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco permessi dato elenco funzioni
|
|
/// </summary>
|
|
/// <param name="ListCodFun"></param>
|
|
/// <returns></returns>
|
|
public List<PermessiModel> PermessiGetByFunc(List<string> ListCodFun)
|
|
{
|
|
List<PermessiModel> dbResult = new List<PermessiModel>();
|
|
using (AppAuthContext dbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
var listPer = PermessiGetAll();
|
|
var listP2F = Permessi2FunzioneGetFilt(ListCodFun);
|
|
|
|
var query = from permesso in listPer
|
|
join p2f in listP2F on permesso.CodPermesso equals p2f.CodPermesso
|
|
select permesso;
|
|
|
|
dbResult = query.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Elenco Record x gestione Update
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<UpdMan> UpdManGetAll()
|
|
{
|
|
List<UpdMan> dbResult = new List<UpdMan>();
|
|
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetUpdMan
|
|
.OrderBy(x => x.Ordinal)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Record x gestione Update
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<VocabolarioModel> VocabolarioGetAll()
|
|
{
|
|
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
|
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
|
|
{
|
|
dbResult = localDbCtx
|
|
.DbSetVocabolario
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static IConfiguration _configuration;
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |