From 8e096a1157c6c036b1952792406ecbd628d33e1d Mon Sep 17 00:00:00 2001 From: Marco Audiffredi Date: Mon, 15 Jul 2024 15:00:30 +0200 Subject: [PATCH] aggiunta prog su destinazioni --- Controllers/GiriController.cs | 134 +++++++++++++++++++++++++++++++++- Models/Destinazioni.cs | 2 + Models/Destinazioni_out.cs | 3 + 3 files changed, 138 insertions(+), 1 deletion(-) diff --git a/Controllers/GiriController.cs b/Controllers/GiriController.cs index 8e46c42..110081c 100644 --- a/Controllers/GiriController.cs +++ b/Controllers/GiriController.cs @@ -261,6 +261,57 @@ namespace ApiSoftway.Controllers } } + [HttpPost] + [Route("modGiro")] + public async Task> modGiro(GiriConsegnaView model) + { + GiriConsegna_out tOut = new GiriConsegna_out(); + + try + { + //step 1 : calcolo il nuovo seriale + + GiriConsegna gc = new GiriConsegna(); + gc.Pisergir = model.SerialeGiro; + gc.Pidarecu = model.ImportoDaRecuperare; + gc.Piautist = model.CodAutista; + gc.Pirecupe = model.ImportoRecuperato; + gc.Pidata = model.DataGiro; + gc.Pidatchi = null; + gc.Pitbancar = model.BancaliCaricati; + gc.Pitbanrec = null; + gc.Pimezzo = model.CodMezzo; + + using (var transactionGiri = _giricons_context.Database.BeginTransaction()) + { + _giricons_context.Entry(gc).State = EntityState.Modified; + await _giricons_context.SaveChangesAsync(); + transactionGiri.Commit(); + } + _giriConsView = _consegnevista_context.GiriView; + var giro = await _giriConsView.Where(t => t.SerialeGiro != null && t.SerialeGiro.Equals(model.SerialeGiro)).FirstAsync(); + tOut.Pisergir = giro.SerialeGiro; + tOut.Pirecupe = giro.ImportoRecuperato; + tOut.Pidarecu = giro.ImportoDaRecuperare; + tOut.Piautist = giro.CodAutista; + tOut.Pidata = giro.DataGiro; + tOut.Pidatchi = giro.DataChiusura; + tOut.Pitbancar = giro.BancaliCaricati; + tOut.Pitbanrec = giro.BancaliRecuperati; + + + return StatusCode(StatusCodes.Status200OK, tOut); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + tOut.err_title = ex.Message; + tOut.err_detail = errmsg; + tOut.err_status_code = "500"; + return StatusCode(StatusCodes.Status500InternalServerError, tOut); + } + } + [HttpPost] [Route("delGiro")] public async Task> delGiro(string? serialeGiro, string? autista, DateTime? data) @@ -398,6 +449,9 @@ namespace ApiSoftway.Controllers o.num_cons = d.num_cons; o.Uova=d.Uova; o.Cist=d.Cist; + o.Note = d.Note; + o.Seq = d.Seq; + o.Prog = d.Prog; if (!string.IsNullOrEmpty(d.consFattaSerial)) { @@ -472,8 +526,9 @@ namespace ApiSoftway.Controllers o.num_cons = d.num_cons; o.Uova=d.Uova; o.Cist=d.Cist; - o.Note=d.Note; + o.Note = d.Note; o.Seq = d.Seq; + o.Prog = d.Prog; if (!string.IsNullOrEmpty(d.consFattaSerial)) @@ -500,6 +555,83 @@ namespace ApiSoftway.Controllers return lst; } + [HttpGet("listaDestinazioneBySerial")] + public async Task> listaDestinazioneBySerial(string seriale) + { + + Destinazioni_out lst = new Destinazioni_out(); + _destinazioni = _destinazioni_context.Destinazioni; + var r = await _destinazioni.Where(t => t.Brserial != null && t.Brserial.Equals(seriale)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).FirstAsync(); + + Destinazioni_out o = new Destinazioni_out(); + string _aut = !string.IsNullOrEmpty(r.Autista) ? r.Autista.Trim() : string.Empty; + o.Autista = _aut; + + string _autCod = !string.IsNullOrEmpty(r.CodAutista) ? r.CodAutista.Trim() : string.Empty; + o.CodAutista = _autCod; + + string _automezzo = !string.IsNullOrEmpty(r.DescAutomezzo) ? r.DescAutomezzo.Trim() : string.Empty; + o.DescAutomezzo = _automezzo; + + string _automezzoCod = !string.IsNullOrEmpty(r.CodAutomezzo) ? r.CodAutomezzo.Trim() : string.Empty; + o.CodAutomezzo = r.CodAutomezzo; + + o.DataCarico = r.DataCarico; + o.Brserial = r.Brserial; + o.Brmerce = r.Brmerce; + o.Brnote = r.Brnote; + o.Cproword = r.Cproword; + o.Cprownum = r.Cprownum; + + string _sedeInd = !string.IsNullOrEmpty(r.IndirizzoSede) ? r.IndirizzoSede.Trim() : string.Empty; + o.IndirizzoSede = _sedeInd; + + string _sede = !string.IsNullOrEmpty(r.Sede) ? r.Sede.Trim() : string.Empty; + o.Sede = _sede; + o.CodCommittente = r.CodCommittente; + + string _committente = !string.IsNullOrEmpty(r.Committente) ? r.Committente.Trim() : string.Empty; + o.Committente = _committente; + + o.CodSede = r.CodSede; + o.ItemList = formattaDestinazione(r); + o.ImportoDaRitirare = r.ImportoDaRitirare; + o.serialeGiro = r.serialeGiro; + o.Casse = r.Casse; + o.Trasf = r.Trasf; + o.Colli = r.Colli; + o.num_cons = r.num_cons; + o.Uova = r.Uova; + o.Cist = r.Cist; + o.Note = r.Note; + o.Seq = r.Seq; + o.Prog=r.Prog; + + + if (!string.IsNullOrEmpty(r.consFattaSerial)) + { + ConsegnaFatta cf = new ConsegnaFatta(); + cf.consFattaSerial = r.consFattaSerial; + cf.consFattaRow = r.consFattaRow; + cf.consFattaAut = r.consFattaAut; + cf.consFattaBanSca = r.consFattaBanSca; + cf.consFattaBanCar = r.consFattaBanCar; + string nota = !string.IsNullOrEmpty(r.consFattaNotBan) ? r.consFattaNotBan.Trim() : string.Empty; + cf.consFattaNotBan = nota; + cf.consFattaImpor = r.consFattaImpor; + cf.consFattaMezzo = r.consFattaMezzo; + string nota2 = !string.IsNullOrEmpty(r.consFattaNotImp) ? r.consFattaNotImp.Trim() : string.Empty; + cf.consFattaNotImp = nota2; + cf.consFattaFlagCons = r.consFattaFlagCons; + + o.ConsFatta = cf; + } + + + + return o; + } + /// Salva i dati della consegna [HttpPost] [Route("destinazione/salva")] diff --git a/Models/Destinazioni.cs b/Models/Destinazioni.cs index d4ebe62..5076b22 100644 --- a/Models/Destinazioni.cs +++ b/Models/Destinazioni.cs @@ -52,5 +52,7 @@ namespace ApiSoftway.Models public string? Note { get; set; } public int? Seq { get; set; } + //progressivo- chiave tabella pimodgir + public string? Prog { get; set; } } } diff --git a/Models/Destinazioni_out.cs b/Models/Destinazioni_out.cs index 8e7b305..40478e2 100644 --- a/Models/Destinazioni_out.cs +++ b/Models/Destinazioni_out.cs @@ -37,6 +37,9 @@ namespace ApiSoftway.Models public int? Cist { get; set; } public string? Note { get; set; } public int? Seq { get; set; } + + //progressivo- chiave tabella pimodgir + public string? Prog { get; set; } } public class ConsegnaFatta {