diff --git a/ApiAdHoc_Odoo/Controllers/ArticoliController.cs b/ApiAdHoc_Odoo/Controllers/ArticoliController.cs new file mode 100644 index 0000000..d52acbe --- /dev/null +++ b/ApiAdHoc_Odoo/Controllers/ArticoliController.cs @@ -0,0 +1,29 @@ +using ApiAdHoc_Odoo.Data; +using ApiAdHoc_Odoo.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace ApiAdHoc_Odoo.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ArticoliController : ControllerBase + { + private readonly PiDbContext _articoliContext; + + public ArticoliController(PiDbContext articoliContext) + { + _articoliContext = articoliContext; + } + + [HttpGet] + public async Task>> GetApiArticoli() + { + var articoliList = _articoliContext.Articolo.ToListAsync(); + + return await articoliList; + } + + } +} diff --git a/ApiAdHoc_Odoo/Controllers/ScadenzeController.cs b/ApiAdHoc_Odoo/Controllers/ScadenzeController.cs new file mode 100644 index 0000000..df1ac9a --- /dev/null +++ b/ApiAdHoc_Odoo/Controllers/ScadenzeController.cs @@ -0,0 +1,29 @@ +using ApiAdHoc_Odoo.Data; +using ApiAdHoc_Odoo.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace ApiAdHoc_Odoo.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ScadenzeController : ControllerBase + { + private readonly PiDbContext _scadenzeContext; + + public ScadenzeController(PiDbContext scadenzeContext) + { + _scadenzeContext = scadenzeContext; + } + + [HttpGet("{codAzi}/{codCli}")] + public async Task>> GetApiScadenze(string codAzi, string codCli) + { + var scadenzeList = _scadenzeContext.Scadenza. + Where(x => x.Azienda == codAzi && x.Cliente == codCli).OrderBy(x => x.Scadenza).ToListAsync(); + + return await scadenzeList; + } + } +} diff --git a/ApiAdHoc_Odoo/Data/PiDbContext.cs b/ApiAdHoc_Odoo/Data/PiDbContext.cs index 26fffb3..4010a4e 100644 --- a/ApiAdHoc_Odoo/Data/PiDbContext.cs +++ b/ApiAdHoc_Odoo/Data/PiDbContext.cs @@ -10,18 +10,28 @@ namespace ApiAdHoc_Odoo.Data public DbSet Clienti { get; set; } public DbSet Fattura { get; set; } - + public DbSet Scadenza { get; set; } + public DbSet Articolo { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { // Map the view to the model modelBuilder.Entity() - .ToView("PI_APICLIENTI")/*;*/ + .ToView("PI_APICLIENTI") .HasNoKey(); // Views typically don't have a primary key // Map the view to the model modelBuilder.Entity() - .ToView("PI_APIFATTURE")/*;*/ + .ToView("PI_APIFATTURE") .HasNoKey(); // Views typically don't have a primary key + // Map the view to the model + modelBuilder.Entity() + .ToView("PI_APISCADENZE2") + .HasNoKey(); // Views typically don't have a primary key + // Map the view to the model + modelBuilder.Entity() + .ToView("PI_APIARTICOLI") + .HasNoKey(); // Views typically don't have a primary key + } } } diff --git a/ApiAdHoc_Odoo/Models/Articolo.cs b/ApiAdHoc_Odoo/Models/Articolo.cs new file mode 100644 index 0000000..a6b867a --- /dev/null +++ b/ApiAdHoc_Odoo/Models/Articolo.cs @@ -0,0 +1,10 @@ +namespace ApiAdHoc_Odoo.Models +{ + public class Articolo + { + //public string? Azienda { get; set; } + public string? CodArticolo { get; set; } + public string? Descrizione { get; set; } + public string? DescriSupplementare { get; set; } + } +} diff --git a/ApiAdHoc_Odoo/Models/Cliente.cs b/ApiAdHoc_Odoo/Models/Cliente.cs index c0a2106..33b41ac 100644 --- a/ApiAdHoc_Odoo/Models/Cliente.cs +++ b/ApiAdHoc_Odoo/Models/Cliente.cs @@ -4,21 +4,21 @@ namespace ApiAdHoc_Odoo.Models { public class Cliente { - public string Azienda { get; set; } - public string Codice { get; set; } - public string Descrizione { get; set; } - public string Partiva { get; set; } - public string CodFisc { get; set; } - public string Telefono { get; set; } - public string Cellulare { get; set; } - public string Email { get; set; } - public string Indirizzo { get; set; } - public string Citta { get; set; } - public string Cap { get; set; } - public string Provincia { get; set; } - public string CodAgente { get; set; } - public string DescriAgente { get; set; } - public int Blocco { get; set; } - public DateTime Obsolescenza { get; set; } + public string? Azienda { get; set; } + public string? Codice { get; set; } + public string? Descrizione { get; set; } + public string? Partiva { get; set; } + public string? CodFisc { get; set; } + public string? Telefono { get; set; } + public string? Cellulare { get; set; } + public string? Email { get; set; } + public string? Indirizzo { get; set; } + public string? Citta { get; set; } + public string? Cap { get; set; } + public string? Provincia { get; set; } + public string? CodAgente { get; set; } + public string? DescriAgente { get; set; } + public int? Blocco { get; set; } + public DateTime? Obsolescenza { get; set; } } } diff --git a/ApiAdHoc_Odoo/Models/Fattura.cs b/ApiAdHoc_Odoo/Models/Fattura.cs index 046d3b8..25943ca 100644 --- a/ApiAdHoc_Odoo/Models/Fattura.cs +++ b/ApiAdHoc_Odoo/Models/Fattura.cs @@ -2,12 +2,12 @@ { public class Fattura { - public string Azienda { get; set; } - public string CodCliente { get; set; } - public string Descrizione { get; set; } - public string Classe { get; set; } - public DateTime DataDocumento { get; set; } - public string Documento { get; set; } - public decimal Totale { get; set; } + public string? Azienda { get; set; } + public string? CodCliente { get; set; } + public string? Descrizione { get; set; } + public string? Classe { get; set; } + public DateTime? DataDocumento { get; set; } + public string? Documento { get; set; } + public decimal? Totale { get; set; } } } diff --git a/ApiAdHoc_Odoo/Models/Scadenze.cs b/ApiAdHoc_Odoo/Models/Scadenze.cs new file mode 100644 index 0000000..443eaf0 --- /dev/null +++ b/ApiAdHoc_Odoo/Models/Scadenze.cs @@ -0,0 +1,19 @@ +namespace ApiAdHoc_Odoo.Models +{ + public class Scadenze + { + public string? Azienda { get; set; } + public string? Partita { get; set; } + public DateTime? Scadenza { get; set; } + public string? Cliente { get; set; } + public string? Dare_Avere { get; set; } + public decimal/*string*/? Totale_Importo { get; set; } + public string? Modalita_Pagamento { get; set; } + public decimal/*string*/? Documento { get; set; } + public string? Alfa { get; set; } + public DateTime? Data_Documento { get; set; } + public string? Seriale_Partita { get; set; } + public DateTime? Apertura { get; set; } + public string? Flag_Cr_Sa { get; set; } + } +}