Aggiunti model scadenze e articoli + chiamata alla vista su dbcontext e controller per scadenze e articoli
This commit is contained in:
parent
a22d21f30c
commit
eebed847bc
29
ApiAdHoc_Odoo/Controllers/ArticoliController.cs
Normal file
29
ApiAdHoc_Odoo/Controllers/ArticoliController.cs
Normal file
@ -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<ActionResult<IEnumerable<Articolo>>> GetApiArticoli()
|
||||
{
|
||||
var articoliList = _articoliContext.Articolo.ToListAsync();
|
||||
|
||||
return await articoliList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
29
ApiAdHoc_Odoo/Controllers/ScadenzeController.cs
Normal file
29
ApiAdHoc_Odoo/Controllers/ScadenzeController.cs
Normal file
@ -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<ActionResult<IEnumerable<Scadenze>>> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,18 +10,28 @@ namespace ApiAdHoc_Odoo.Data
|
||||
|
||||
public DbSet<Cliente> Clienti { get; set; }
|
||||
public DbSet<Fattura> Fattura { get; set; }
|
||||
|
||||
public DbSet<Scadenze> Scadenza { get; set; }
|
||||
public DbSet<Articolo> Articolo { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
// Map the view to the model
|
||||
modelBuilder.Entity<Cliente>()
|
||||
.ToView("PI_APICLIENTI")/*;*/
|
||||
.ToView("PI_APICLIENTI")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
// Map the view to the model
|
||||
modelBuilder.Entity<Fattura>()
|
||||
.ToView("PI_APIFATTURE")/*;*/
|
||||
.ToView("PI_APIFATTURE")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
// Map the view to the model
|
||||
modelBuilder.Entity<Scadenze>()
|
||||
.ToView("PI_APISCADENZE2")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
// Map the view to the model
|
||||
modelBuilder.Entity<Articolo>()
|
||||
.ToView("PI_APIARTICOLI")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
ApiAdHoc_Odoo/Models/Articolo.cs
Normal file
10
ApiAdHoc_Odoo/Models/Articolo.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
19
ApiAdHoc_Odoo/Models/Scadenze.cs
Normal file
19
ApiAdHoc_Odoo/Models/Scadenze.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user