diff --git a/Controllers/GiriController.cs b/Controllers/GiriController.cs index 5f8a43f..22c1975 100644 --- a/Controllers/GiriController.cs +++ b/Controllers/GiriController.cs @@ -3,6 +3,7 @@ using ApiSoftway.Models.Gesa_DbContext; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; using System.Diagnostics; @@ -26,6 +27,8 @@ namespace ApiSoftway.Controllers private readonly GESA_SBR_ORD_DbContext _sbrord_context; private readonly GESA_PERSONALE_DbContext _personale_context; private readonly IConfiguration? _configuration; + private readonly GESA_GIRICONSEGNEDACREARE_DbContext _daCreare_context; + private DbSet? _giri; private DbSet? _giriCons; private DbSet? _giriConsView; @@ -33,9 +36,10 @@ namespace ApiSoftway.Controllers private DbSet? _consegne; private DbSet? _sbrord; private DbSet? _personale; + private DbSet? _GiriDaCreare; public GiriController(ILogger logger, IConfiguration? configuration, GESA_GIRI_DbContext giri_context, GESA_DESTINAZIONI_DbContext destinazioni_context , GESA_CONSEGNE_DbContext consegne_context, GESA_GIRICONSEGNE_DbContext giricons_context, GESA_GIRICONSEGNEVISTA_DbContext consegnevista_context, GESA_SBR_ORD_DbContext sbrord_context - , GESA_PERSONALE_DbContext personale_context) + , GESA_PERSONALE_DbContext personale_context, GESA_GIRICONSEGNEDACREARE_DbContext daCreare_context) { _logger = logger; _configuration = configuration; @@ -46,6 +50,7 @@ namespace ApiSoftway.Controllers _consegnevista_context = consegnevista_context; _sbrord_context = sbrord_context; _personale_context= personale_context; + _daCreare_context = daCreare_context; } [HttpGet("listaGiri")] @@ -68,6 +73,16 @@ namespace ApiSoftway.Controllers return gc; } + [HttpGet("listaGiriDaCreare")] + public async Task>> listaGiriDaCreare() + { + List lst = new List(); + _GiriDaCreare = _daCreare_context.GiriDaCreare; + var gc = await _GiriDaCreare.OrderByDescending(t => t.DataGiro).ToListAsync() ; + + return gc; + } + [HttpGet("listaAutisti")] public async Task>> listaAutisti() { @@ -376,6 +391,13 @@ namespace ApiSoftway.Controllers o.ItemList = formattaDestinazione(d); o.ImportoDaRitirare = d.ImportoDaRitirare; o.serialeGiro=d.serialeGiro; + o.Casse = d.Casse; + o.Trasf=d.Trasf; + o.Colli=d.Colli; + o.num_cons = d.num_cons; + o.Uova=d.Uova; + o.Cist=d.Cist; + if (!string.IsNullOrEmpty(d.consFattaSerial)) { ConsegnaFatta cf=new ConsegnaFatta(); @@ -400,13 +422,13 @@ namespace ApiSoftway.Controllers return lst; } - [HttpGet("listaDestinazioniByAutistaData")] - public async Task>> listaDestinazioniByAutistaData(string autista, DateTime? dataGiro) + [HttpGet("listaDestinazioniByAutistaDataMezzo")] + public async Task>> listaDestinazioniByAutistaData(string autista, DateTime? dataGiro,string mezzo) { List lst = new List(); _destinazioni = _destinazioni_context.Destinazioni; - var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro).OrderByDescending(t => t.DataCarico).ToListAsync(); + var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro && t.CodAutomezzo!=null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ToListAsync(); foreach (Destinazioni d in r) { Destinazioni_out o = new Destinazioni_out(); @@ -443,6 +465,15 @@ namespace ApiSoftway.Controllers o.ItemList = formattaDestinazione(d); o.ImportoDaRitirare = d.ImportoDaRitirare; o.serialeGiro = d.serialeGiro; + o.Casse=d.Casse; + o.Trasf=d.Trasf; + o.Colli=d.Colli; + o.num_cons = d.num_cons; + o.Uova=d.Uova; + o.Cist=d.Cist; + o.Note=d.Note; + + if (!string.IsNullOrEmpty(d.consFattaSerial)) { ConsegnaFatta cf = new ConsegnaFatta(); @@ -609,6 +640,44 @@ namespace ApiSoftway.Controllers string ind = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty; sb.Append("Indirizzo " + ind); sb.Append("
"); + + string _casse=d.Casse!=null && d.Casse >0 ? Convert.ToInt16(d.Casse).ToString() : string.Empty; + if(!string.IsNullOrEmpty(_casse)) + { + sb.Append("Casse " + _casse + " "); + } + string _trasf = d.Trasf != null && d.Trasf > 0 ? Convert.ToInt16( d.Trasf).ToString() : string.Empty; + if (!string.IsNullOrEmpty(_trasf)) + { + sb.Append("Trasf " + _trasf + " "); + } + string _colli = d.Colli != null && d.Colli > 0 ? Convert.ToInt16(d.Colli).ToString() : string.Empty; + if (!string.IsNullOrEmpty(_colli)) + { + sb.Append("Colli " + _colli + " "); + } + string _num_cons = d.num_cons != null && d.num_cons > 0 ? Convert.ToInt16(d.num_cons).ToString() : string.Empty; + if (!string.IsNullOrEmpty(_num_cons)) + { + sb.Append("Nr.Cons " + _num_cons + " "); + } + string _uova = d.Uova != null && d.Uova > 0 ? d.Uova.ToString() : string.Empty; + if (!string.IsNullOrEmpty(_uova)) + { + sb.Append("Uova " + _uova + " "); + } + string _cist = d.Cist != null && d.Cist > 0 ? d.Cist.ToString() : string.Empty; + if (!string.IsNullOrEmpty(_cist)) + { + sb.Append("Cist " + _cist + " "); + } + string _note=!string.IsNullOrEmpty(d.Note) ? d.Note.Trim() :string.Empty; + if (!string.IsNullOrEmpty(_note)) + { + sb.Append("
"); + sb.Append("Note " + _note); + } + item = sb.ToString(); sb = null; } diff --git a/Models/Destinazioni.cs b/Models/Destinazioni.cs index e7b51c6..0cb44da 100644 --- a/Models/Destinazioni.cs +++ b/Models/Destinazioni.cs @@ -39,5 +39,17 @@ namespace ApiSoftway.Models public string? serialeGiro { get; set; } + + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? Casse { get; set; } + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? Trasf { get; set; } + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? Colli { get; set; } + public int? num_cons { get; set; } + public int? Uova { get; set; } + public int? Cist { get; set; } + public string? Note { get; set; } + } } diff --git a/Models/Destinazioni_out.cs b/Models/Destinazioni_out.cs index 41adeb3..7f8657e 100644 --- a/Models/Destinazioni_out.cs +++ b/Models/Destinazioni_out.cs @@ -25,6 +25,17 @@ namespace ApiSoftway.Models public string? ItemList { get; set; } public ConsegnaFatta? ConsFatta { get; set; } public string? serialeGiro { get; set; } + + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? Casse { get; set; } + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? Trasf { get; set; } + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? Colli { get; set; } + public int? num_cons { get; set; } + public int? Uova { get; set; } + public int? Cist { get; set; } + public string? Note { get; set; } } public class ConsegnaFatta { diff --git a/Models/Gesa_DbContext/GESA_GIRICONSEGNEDACREARE_DbContext.cs b/Models/Gesa_DbContext/GESA_GIRICONSEGNEDACREARE_DbContext.cs new file mode 100644 index 0000000..3093711 --- /dev/null +++ b/Models/Gesa_DbContext/GESA_GIRICONSEGNEDACREARE_DbContext.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiSoftway.Models.Gesa_DbContext +{ + public class GESA_GIRICONSEGNEDACREARE_DbContext : DbContext + { + public DbSet? GiriDaCreare { get; set; } + public GESA_GIRICONSEGNEDACREARE_DbContext(DbContextOptions options) : base(options) + { + } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_GIRICONSEGNA_DA_CREARE"); + } + } +} diff --git a/Models/GiriConsegnaDaCreare.cs b/Models/GiriConsegnaDaCreare.cs new file mode 100644 index 0000000..fc30bba --- /dev/null +++ b/Models/GiriConsegnaDaCreare.cs @@ -0,0 +1,14 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiSoftway.Models +{ + [Keyless] + public class GiriConsegnaDaCreare + { + public string? CodAutomezzo { get; set; } + public string? CodAutista { get; set; } + public string? Autista { get; set; } + public string? Automezzo { get; set; } + public DateTime? DataGiro { get; set; } + } +} diff --git a/Models/GiriConsegnaDaCreare_out.cs b/Models/GiriConsegnaDaCreare_out.cs new file mode 100644 index 0000000..32d7972 --- /dev/null +++ b/Models/GiriConsegnaDaCreare_out.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiSoftway.Models +{ + [Keyless] + public class GiriConsegnaDaCreare_out + { + public string? CodAutomezzo { get; set; } + public string? CodAutista { get; set; } + public string? Autista { get; set; } + public string? Automezzo { get; set; } + public DateTime? DataGiro { get; set; } + + /// errore titolo + public string? err_title { get; set; } + /// errore dettaglio + public string? err_detail { get; set; } + /// errore status code (200, 500) + public string? err_status_code { get; set; } + } +} diff --git a/Models/GiriConsegnaView.cs b/Models/GiriConsegnaView.cs index 93b19a5..01e3908 100644 --- a/Models/GiriConsegnaView.cs +++ b/Models/GiriConsegnaView.cs @@ -19,5 +19,8 @@ namespace ApiSoftway.Models public decimal? ImportoRecuperato { get; set; } public DateTime? DataChiusura { get; set; } + public string? CodMezzo { get; set; } + public string? Automezzo { get; set; } + } } diff --git a/Program.cs b/Program.cs index 62f75b7..caa2202 100644 --- a/Program.cs +++ b/Program.cs @@ -39,6 +39,9 @@ builder.Services.AddDbContext(options => optio builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA") , options => { options.CommandTimeout(commandTimeoutInSeconds); } )); +builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); #endregion