diff --git a/Controllers/DestinazioniController.cs b/Controllers/DestinazioniController.cs index 6fbc347..f3498eb 100644 --- a/Controllers/DestinazioniController.cs +++ b/Controllers/DestinazioniController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; using SoftwayWeb.Models; +using System.Diagnostics; using System.Text; using X.PagedList; @@ -97,14 +98,14 @@ namespace SoftwayWeb.Controllers } - [HttpPost] - public IActionResult EliminaDestinazione(string seriale) + + public IActionResult EliminaDestinazione(string serial) { SessionHelper helper = new SessionHelper(this); apiUrl = helper.GetStringValue("apiUrl"); - urlBase = apiUrl + "Giri/listaDestinazioniBySerial"; - urlBase = urlBase + "?seriale=" + seriale; + urlBase = apiUrl + "Giri/listaDestinazioneBySerial"; + urlBase = urlBase + "?seriale=" + serial; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); @@ -118,6 +119,33 @@ namespace SoftwayWeb.Controllers model = JsonConvert.DeserializeObject(dato); //qui metodo post per scrivere su pimodgir + Modgir mg=new Modgir(); + mg.Piserial = model.Brserial; + mg.Pidata = model.DataCarico; + mg.Picommit = model.CodCommittente; + mg.Pidesdiv = model.CodSede; + mg.Pitarga = model.CodAutomezzo; + mg.Piautist = model.CodAutista; + mg.Pitiprec = "D"; + + urlBase = apiUrl + "ModificaGiro/addModgir"; + baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + string data = JsonConvert.SerializeObject(mg); + StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); + HttpResponseMessage response2 = client.PostAsync(baseAddress, content).Result; + if (response2.IsSuccessStatusCode) + { + + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } } else { @@ -126,7 +154,21 @@ namespace SoftwayWeb.Controllers return RedirectToAction("Error"); } - return RedirectToAction("Index", "Giri"); + return RedirectToAction("Index", "Destinazioni", new + { + id = model.Brserial, + codAutista = model.CodAutista, + dataGiro = model.DataCarico, + codMezzo=model.CodAutomezzo + }); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + SessionHelper helper = new SessionHelper(this); + string e = helper.GetStringValue("errMsg"); + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e }); } } } diff --git a/Models/Modgir.cs b/Models/Modgir.cs new file mode 100644 index 0000000..c250a6f --- /dev/null +++ b/Models/Modgir.cs @@ -0,0 +1,15 @@ +namespace SoftwayWeb.Models +{ + public class Modgir + { + public string? Piprogre { get; set; } + public string? Piserial { get; set; } + public DateTime? Pidata { get; set; } + public string? Picommit { get; set; } + public string? Pidesdiv { get; set; } + public string? Pitarga { get; set; } + public string? Piautist { get; set; } + public string? Pitiprec { get; set; } + public string? Pirigele { get; set; } + } +} diff --git a/Models/Modgir_out.cs b/Models/Modgir_out.cs new file mode 100644 index 0000000..f4df53a --- /dev/null +++ b/Models/Modgir_out.cs @@ -0,0 +1,22 @@ +namespace SoftwayWeb.Models +{ + public class Modgir_out + { + public string? Piprogre { get; set; } + public string? Piserial { get; set; } + public DateTime? Pidata { get; set; } + public string? Picommit { get; set; } + public string? Pidesdiv { get; set; } + public string? Pitarga { get; set; } + public string? Piautist { get; set; } + public string? Pitiprec { get; set; } + public string? Pirigele { 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/Views/Destinazioni/Index.cshtml b/Views/Destinazioni/Index.cshtml index 910e0d2..9ef241d 100644 --- a/Views/Destinazioni/Index.cshtml +++ b/Views/Destinazioni/Index.cshtml @@ -137,7 +137,7 @@ @Html.DisplayFor(modelItem => item.Note) - nocons + nocons