59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using ApiSoftway.Models;
|
|
using ApiSoftway.Models.Gesa_DbContext;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ApiSoftway.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class ClientiController : ControllerBase
|
|
{
|
|
private readonly GESA_CLIENTI_DbContext _dbClientiContext;
|
|
private readonly GESA_SEDECONSEGNA_DbContext _dbsedeconsegnaContext;
|
|
private DbSet<Clienti> _clienti;
|
|
private DbSet<SedeConsegna> _sedeconsegna;
|
|
private readonly ILogger<LoginController> _logger;
|
|
private readonly IConfiguration? _configuration;
|
|
|
|
public ClientiController(GESA_CLIENTI_DbContext dbClientiContext, GESA_SEDECONSEGNA_DbContext dbsedeconsegnaContext, ILogger<LoginController> logger, IConfiguration? configuration)
|
|
{
|
|
_dbClientiContext = dbClientiContext;
|
|
_dbsedeconsegnaContext = dbsedeconsegnaContext;
|
|
_logger = logger;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
[HttpGet("GetCommittenti")]
|
|
public async Task<ActionResult<IEnumerable<Clienti>>> GetClienti()
|
|
{
|
|
List<Clienti> listClienti = new List<Clienti>();
|
|
_clienti = _dbClientiContext.Cli;
|
|
var lista = await _clienti.Where(x => x.Antipcon.Equals("C")).OrderBy(x => x.Andescri).ToListAsync();
|
|
|
|
foreach (var client in lista)
|
|
{
|
|
listClienti.Add(client);
|
|
}
|
|
|
|
return listClienti;
|
|
}
|
|
|
|
[HttpGet("GetSediByCommittente")]
|
|
public async Task<ActionResult<IEnumerable<SedeConsegna>>> GetSediByCommittente(string codCom)
|
|
{
|
|
List<SedeConsegna> listSedi = new List<SedeConsegna>();
|
|
_sedeconsegna = _dbsedeconsegnaContext.SedeConsegna;
|
|
var listaSedi = await _sedeconsegna.Where(x => x.Pccodcon.Contains(codCom)).ToListAsync();
|
|
|
|
foreach (var sede in listaSedi)
|
|
{
|
|
listSedi.Add(sede);
|
|
}
|
|
|
|
return listSedi;
|
|
}
|
|
}
|
|
}
|