implementazione interfaccie e factory per dbcontext universali creato TestController per esempi
138 lines
5.7 KiB
C#
138 lines
5.7 KiB
C#
using ApiPolo.Interfaces;
|
|
using ApiPolo.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ApiPolo.Controllers
|
|
{
|
|
public class TestController : Controller
|
|
{
|
|
//interfaccia con tutti i possibili dbset
|
|
private readonly ITenantDbContextFactory _dbContextFactory;
|
|
//DI con ITenantDbContextFactory
|
|
public TestController(ITenantDbContextFactory dbContextFactory)
|
|
{
|
|
_dbContextFactory = dbContextFactory;
|
|
}
|
|
|
|
//ATTENZIONE - CONFLITTO TRA Compo_Impia_Table e
|
|
|
|
#region GET_BY_TENANT
|
|
private DbSet<Tecnici> getTecniciByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Tecnici; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Rapp_New> getRappNewByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Rapps; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Chiamate> getChiamateByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Chiamate; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Chiusure>? getChiusureByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Chiusure;
|
|
}
|
|
private DbSet<Manprog> getManutenzioniByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Manutenzioni; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Prese> getPreseByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Prese; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Sto_Rapp> getSto_RappByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.StoRapp; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Anag> getClientiByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Clienti; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Caus_Rapp> getCausaliRappByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Causali; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Pagam> getPagamentiByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Pagamenti; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
|
|
private DbSet<Saldiart> getSaldiartByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Saldi; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
/// <summary>
|
|
/// CONFLITTO CON Compo_Impia_Table
|
|
/// </summary>
|
|
/*
|
|
private DbSet<Compo_Impia_Table> getComponentiByTenant(string tenant)
|
|
{ // IN CONFLITTO CON Compo_Impia_Table
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Componen; // Use Set<T>() to handle different DbContexts
|
|
}*/
|
|
private DbSet<Compo_Impia_Table> getComponentiTableByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Componen; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Magazzini> getMagazziniByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Magaz; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Mag_New> getMag_NewByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Mag; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Impianto> getImpiantiByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Impia; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Commessa> getCommesseByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Commesse; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Timbratura> getTimbratureByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Timbr; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
|
|
private DbSet<Sto_Imp> getStoricoImpiantoByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.StoImp; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<AziendaRif> getAziendeRifByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Azi; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
private DbSet<Sostituzione> getSostituzioneByTenant(string tenant)
|
|
{
|
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
|
return dbContext.Sost; // Use Set<T>() to handle different DbContexts
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
}
|