Aggiunti model, dbset e controller per Clienti Contratti attivi e clienti max prezzi
This commit is contained in:
parent
d2ff29f1b6
commit
236fbe7a63
35
ApiAdHoc_Odoo/Controllers/ClientiContrAttiviController.cs
Normal file
35
ApiAdHoc_Odoo/Controllers/ClientiContrAttiviController.cs
Normal file
@ -0,0 +1,35 @@
|
||||
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 ClientiContrAttiviController : ControllerBase
|
||||
{
|
||||
private readonly PiDbContext _cliContrAttiv;
|
||||
|
||||
public ClientiContrAttiviController(PiDbContext cliContrAttiv)
|
||||
{
|
||||
_cliContrAttiv = cliContrAttiv;
|
||||
}
|
||||
|
||||
[HttpGet("{codAzi}/{codCli}")]
|
||||
public async Task<ActionResult<IEnumerable<ClienteContrAttivi>>> GetCliContrAttivi(string codAzi, string codCli)
|
||||
{
|
||||
var cliContrattList = await _cliContrAttiv.CliContrAttiv.
|
||||
Where(x => x.Azienda == codAzi && x.CoCodCon == codCli).OrderBy(x => x.CoCodCon).ToListAsync();
|
||||
|
||||
if (cliContrattList == null || !cliContrattList.Any())
|
||||
{
|
||||
//return NotFound(); // Restituisce 404 se la lista è vuota
|
||||
return NotFound(new { message = $"Nessun contratto attivo trovato per il cliente: '{codCli.Trim()}' per Azienda: '{codAzi.Trim()}'." });
|
||||
}
|
||||
|
||||
return cliContrattList;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
ApiAdHoc_Odoo/Controllers/ClientiMaxPrezziController.cs
Normal file
35
ApiAdHoc_Odoo/Controllers/ClientiMaxPrezziController.cs
Normal file
@ -0,0 +1,35 @@
|
||||
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 ClientiMaxPrezziController : ControllerBase
|
||||
{
|
||||
private readonly PiDbContext _cliMaxPContext;
|
||||
|
||||
public ClientiMaxPrezziController(PiDbContext cliMaxPContext)
|
||||
{
|
||||
_cliMaxPContext = cliMaxPContext;
|
||||
}
|
||||
|
||||
[HttpGet("{codAzi}/{codCli}")]
|
||||
public async Task<ActionResult<IEnumerable<ClienteMaxPrezzi>>> GetMaxPrezziCli(string codAzi, string codCli)
|
||||
{
|
||||
var maxPrezziCliList = await _cliMaxPContext.CliMaxPrezzi.Where(x => x.Azienda == codAzi && x.CoCodCon == codCli)
|
||||
.OrderBy(x => x.CoCodCon).ToListAsync();
|
||||
|
||||
if (maxPrezziCliList == null || !maxPrezziCliList.Any())
|
||||
{
|
||||
//return NotFound(); // Restituisce 404 se la lista è vuota
|
||||
return NotFound(new { message = $"Non sono stati trovati dei prezzi per il cliente: '{codCli.Trim()}' per Azienda: '{codAzi.Trim()}'." });
|
||||
}
|
||||
|
||||
return maxPrezziCliList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,8 @@ namespace ApiAdHoc_Odoo.Data
|
||||
public DbSet<Fattura> Fattura { get; set; }
|
||||
public DbSet<Scadenze> Scadenza { get; set; }
|
||||
public DbSet<Articolo> Articolo { get; set; }
|
||||
public DbSet<ClienteContrAttivi> CliContrAttiv { get; set; }
|
||||
public DbSet<ClienteMaxPrezzi> CliMaxPrezzi { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -31,6 +33,15 @@ namespace ApiAdHoc_Odoo.Data
|
||||
modelBuilder.Entity<Articolo>()
|
||||
.ToView("PI_APIARTICOLI")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
// Map the view to the model
|
||||
modelBuilder.Entity<ClienteContrAttivi>()
|
||||
.ToView("PI_API_CLICONTR_ATTIVI")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
// Map the view to the model
|
||||
modelBuilder.Entity<ClienteMaxPrezzi>()
|
||||
.ToView("PI_API_CLIMAXPREZZI")
|
||||
.HasNoKey(); // Views typically don't have a primary key
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
26
ApiAdHoc_Odoo/Models/ClienteContrAttivi.cs
Normal file
26
ApiAdHoc_Odoo/Models/ClienteContrAttivi.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApiAdHoc_Odoo.Models
|
||||
{
|
||||
public class ClienteContrAttivi
|
||||
{
|
||||
public string? Azienda { get; set; }
|
||||
public string? CoSerial { get; set; }
|
||||
public string? CoTipCon { get; set; }
|
||||
public string? CoCodCon { get; set; }
|
||||
public string? AnDescri { get; set; }
|
||||
public string? CoDesCon { get; set; }
|
||||
public DateTime? CoDatSti { get; set; }
|
||||
public string? CoPerCon { get; set; }
|
||||
public int? CoNumGio { get; set; }
|
||||
public DateTime? CoDatLim { get; set; }
|
||||
public DateTime? CoDatIni { get; set; }
|
||||
public DateTime? CoDatFin { get; set; }
|
||||
public string? CoRinCon { get; set; }
|
||||
public string? CoFlSosp { get; set; }
|
||||
public string? ElCodArt { get; set; }
|
||||
public string? MoDesCri { get; set; }
|
||||
public decimal? Prezzo_Attuale { get; set; }
|
||||
}
|
||||
}
|
||||
15
ApiAdHoc_Odoo/Models/ClienteMaxPrezzi.cs
Normal file
15
ApiAdHoc_Odoo/Models/ClienteMaxPrezzi.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApiAdHoc_Odoo.Models
|
||||
{
|
||||
public class ClienteMaxPrezzi
|
||||
{
|
||||
public string? Azienda { get; set; }
|
||||
public string? CoCodCon { get; set; }
|
||||
public string? ElCodArt { get; set; }
|
||||
public string? Descrizione { get; set; }
|
||||
public int? Conteggio_Vendite { get; set; }
|
||||
public decimal? Prezzo_Max { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user