diff --git a/Controllers/DestinazioniController.cs b/Controllers/DestinazioniController.cs index 988b84b..c67373e 100644 --- a/Controllers/DestinazioniController.cs +++ b/Controllers/DestinazioniController.cs @@ -258,6 +258,7 @@ namespace SoftwayWeb.Controllers mg.Pitarga = model.CodAutomezzo; mg.Piautist = model.CodAutista; mg.Pitiprec = "D"; + mg.Pisergir = model.serialeGiro; urlBase = apiUrl + "ModificaGiro/addModgir"; baseAddress = new Uri(urlBase); @@ -343,6 +344,92 @@ namespace SoftwayWeb.Controllers } + [HttpPost] + public IActionResult ModificaDestinazioneStep1(Destinazioni_Out model) + { + SessionHelper helper = new SessionHelper(this); + + token = helper.GetStringValue("tok"); + + if (string.IsNullOrEmpty(token)) + { + return RedirectToAction("Login", "Login"); + } + //prima controllo se è un giro nuovo o devo accodare le destinazioni ad un altro utente + string dataGi = string.Empty; + dataGi = model.DataCarico.Value.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'"); + urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzoWeb"; + urlBase = urlBase + "?autista=" + model.CodAutista + "&dataGiro=" + dataGi + "&mezzo=" + model.CodAutomezzo; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + + + + if (response.IsSuccessStatusCode) + { + string dato = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(dato); + var presenti = modelList.OrderByDescending(t => t.Prog); + string mex = string.Empty; + + if (presenti != null && presenti.Count() > 0) + { + //giro già esistente.. accodo + mex = "Accodo"; + } + else + { + // giro non esistente.. ne creo uno nuovo + mex = "Creo nuovo"; + } + ViewBag.Messaggio = mex; + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + return View(model); + + + //apiUrl = helper.GetStringValue("apiUrl"); + + //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) + //{ + + // return RedirectToAction("Index", "Destinazioni", new + // { + // id = model.serialeGiro, + // codAutista = model.CodAutistaOld, + // nomeAutista = model.AutistaOld, + // dataGiro = model.DataCarico, + // codMezzo = model.CodAutomezzoOld, + // desMezzo = model.DescAutomezzoOld + // }); + //} + //else + //{ + // errMes = response2.Content.ReadAsStringAsync().Result; + // helper.SetStringValue("errMsg", errMes); + // return RedirectToAction("Error"); + //} + + } + [HttpPost] public IActionResult ModificaDestinazionePost(Destinazioni_Out model) { @@ -354,8 +441,18 @@ namespace SoftwayWeb.Controllers { return RedirectToAction("Login", "Login"); } + //prima controllo se è un giro nuovo o devo accodare le destinazioni ad un altro utente + string dataGi = string.Empty; + dataGi = model.DataCarico.Value.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'"); + urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzoWeb"; + urlBase = urlBase + "?autista=" + model.CodAutista + "&dataGiro=" + dataGi + "&mezzo=" + model.CodAutomezzo; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; - //qui metodo post per scrivere su pimodgir Modgir mg = new Modgir(); mg.Piserial = model.Brserial; mg.Pidata = model.DataCarico; @@ -363,13 +460,44 @@ namespace SoftwayWeb.Controllers mg.Pidesdiv = model.CodSede; mg.Pitarga = model.CodAutomezzo; mg.Piautist = model.CodAutista; - mg.Pitiprec = "M"; - mg.Pisergir = model.serialeGiro; + + + if (response.IsSuccessStatusCode) + { + string dato = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(dato); + var presenti = modelList.OrderByDescending(t => t.Prog); + + + if (presenti != null && presenti.Count()>0) + { + //giro già esistente.. accodo + mg.Pitiprec = "M"; + mg.Pisergirold = model.serialeGiro; + foreach(Destinazioni_Out d in presenti) + { + mg.Pisergir = d.serialeGiro; + } + } + else + { + // giro non esistente.. ne creo uno nuovo + mg.Pitiprec = "N"; + mg.Pisergir = model.serialeGiro; + } + + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } apiUrl = helper.GetStringValue("apiUrl"); urlBase = apiUrl + "ModificaGiro/addModgir"; - Uri baseAddress = new Uri(urlBase); + baseAddress = new Uri(urlBase); client = new HttpClient(); client.BaseAddress = baseAddress; @@ -477,6 +605,23 @@ namespace SoftwayWeb.Controllers } + #region controllo javascript NON usato + [HttpPost] // can be HttpGet + public ActionResult Test(string codmezzo, string codaut) + { + bool isValid = yourcheckmethod(codmezzo, codaut); //.. check + //bool isValid = true; + var obj = new + { + valid = isValid + }; + return Json(obj); + } + private bool yourcheckmethod(string codmezzo, string codaut) + { + return false; + } + #endregion [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() diff --git a/Controllers/GiriController.cs b/Controllers/GiriController.cs index 7f75714..f96bf67 100644 --- a/Controllers/GiriController.cs +++ b/Controllers/GiriController.cs @@ -345,7 +345,7 @@ namespace SoftwayWeb.Controllers mg.Pitarga = mezzi.TrimEnd(); mg.Piautist = autisti.TrimEnd(); mg.Pitiprec = "M"; - mg.Pisergir = destinazione.Pisergir; + mg.Pisergir = destinazione.serialeGiro; apiUrl = helper.GetStringValue("apiUrl"); diff --git a/Models/Modgir.cs b/Models/Modgir.cs index 29f76a7..7705540 100644 --- a/Models/Modgir.cs +++ b/Models/Modgir.cs @@ -40,5 +40,8 @@ namespace SoftwayWeb.Models [Display(Name = "Note")] public string? Pinote { get; set; } + [Display(Name = "Seriale Giro con destinazioni spostate")] + public string? Pisergirold { get; set; } + } } diff --git a/SoftwayWeb.csproj b/SoftwayWeb.csproj index 5ec5331..616776b 100644 --- a/SoftwayWeb.csproj +++ b/SoftwayWeb.csproj @@ -7,7 +7,7 @@ - + diff --git a/Views/Destinazioni/ModificaDestinazione.cshtml b/Views/Destinazioni/ModificaDestinazione.cshtml index e0be536..bb673ac 100644 --- a/Views/Destinazioni/ModificaDestinazione.cshtml +++ b/Views/Destinazioni/ModificaDestinazione.cshtml @@ -14,7 +14,7 @@
Modifica destinazione
-
+
@@ -73,8 +73,9 @@ @Html.HiddenFor(model => model.CodAutomezzoOld) @Html.HiddenFor(model => model.AutistaOld) @Html.HiddenFor(model => model.DescAutomezzoOld) - - +@* + *@ +
@@ -85,9 +86,6 @@
Dettaglio trasporto
- - -
@Html.DisplayFor(model => model.Casse)
@@ -127,95 +125,63 @@
+ +
Torna alla Lista diff --git a/Views/Destinazioni/ModificaDestinazioneStep1.cshtml b/Views/Destinazioni/ModificaDestinazioneStep1.cshtml new file mode 100644 index 0000000..7df90b1 --- /dev/null +++ b/Views/Destinazioni/ModificaDestinazioneStep1.cshtml @@ -0,0 +1,249 @@ +@model SoftwayWeb.Models.Destinazioni_Out + +@{ + ViewData["Title"] = "ModificaDestinazioneStep1"; + Layout = "~/Views/Shared/_LayoutAreaRis.cshtml"; + string messaggio = string.Empty; + messaggio = ViewBag.Messaggio; +} + +

messaggio di uscita: @messaggio

+ +
+

Destinazioni_Out

+
+
+ +
+
+ @Html.DisplayNameFor(model => model.CodAutomezzo) +
+
+ @Html.DisplayFor(model => model.CodAutomezzo) +
+
+ @Html.DisplayNameFor(model => model.DescAutomezzo) +
+
+ @Html.DisplayFor(model => model.DescAutomezzo) +
+
+ @Html.DisplayNameFor(model => model.Brserial) +
+
+ @Html.DisplayFor(model => model.Brserial) +
+
+ @Html.DisplayNameFor(model => model.DataCarico) +
+
+ @Html.DisplayFor(model => model.DataCarico) +
+
+ @Html.DisplayNameFor(model => model.CodCommittente) +
+
+ @Html.DisplayFor(model => model.CodCommittente) +
+
+ @Html.DisplayNameFor(model => model.Committente) +
+
+ @Html.DisplayFor(model => model.Committente) +
+
+ @Html.DisplayNameFor(model => model.CodAutista) +
+
+ @Html.DisplayFor(model => model.CodAutista) +
+
+ @Html.DisplayNameFor(model => model.Autista) +
+
+ @Html.DisplayFor(model => model.Autista) +
+
+ @Html.DisplayNameFor(model => model.CodSede) +
+
+ @Html.DisplayFor(model => model.CodSede) +
+
+ @Html.DisplayNameFor(model => model.Sede) +
+
+ @Html.DisplayFor(model => model.Sede) +
+
+ @Html.DisplayNameFor(model => model.IndirizzoSede) +
+
+ @Html.DisplayFor(model => model.IndirizzoSede) +
+
+ @Html.DisplayNameFor(model => model.Cproword) +
+
+ @Html.DisplayFor(model => model.Cproword) +
+
+ @Html.DisplayNameFor(model => model.Cprownum) +
+
+ @Html.DisplayFor(model => model.Cprownum) +
+
+ @Html.DisplayNameFor(model => model.Brmerce) +
+
+ @Html.DisplayFor(model => model.Brmerce) +
+
+ @Html.DisplayNameFor(model => model.Brnote) +
+
+ @Html.DisplayFor(model => model.Brnote) +
+
+ @Html.DisplayNameFor(model => model.ImportoDaRitirare) +
+
+ @Html.DisplayFor(model => model.ImportoDaRitirare) +
+
+ @Html.DisplayNameFor(model => model.ItemList) +
+
+ @Html.DisplayFor(model => model.ItemList) +
+
+ @Html.DisplayNameFor(model => model.serialeGiro) +
+
+ @Html.DisplayFor(model => model.serialeGiro) +
+
+ @Html.DisplayNameFor(model => model.Casse) +
+
+ @Html.DisplayFor(model => model.Casse) +
+
+ @Html.DisplayNameFor(model => model.Trasf) +
+
+ @Html.DisplayFor(model => model.Trasf) +
+
+ @Html.DisplayNameFor(model => model.Colli) +
+
+ @Html.DisplayFor(model => model.Colli) +
+
+ @Html.DisplayNameFor(model => model.num_cons) +
+
+ @Html.DisplayFor(model => model.num_cons) +
+
+ @Html.DisplayNameFor(model => model.Uova) +
+
+ @Html.DisplayFor(model => model.Uova) +
+
+ @Html.DisplayNameFor(model => model.Cist) +
+
+ @Html.DisplayFor(model => model.Cist) +
+
+ @Html.DisplayNameFor(model => model.Note) +
+
+ @Html.DisplayFor(model => model.Note) +
+
+ @Html.DisplayNameFor(model => model.Seq) +
+
+ @Html.DisplayFor(model => model.Seq) +
+
+ @Html.DisplayNameFor(model => model.Prog) +
+
+ @Html.DisplayFor(model => model.Prog) +
+
+ @Html.DisplayNameFor(model => model.Pisergir) +
+
+ @Html.DisplayFor(model => model.Pisergir) +
+
+ @Html.DisplayNameFor(model => model.CodAutomezzoOld) +
+
+ @Html.DisplayFor(model => model.CodAutomezzoOld) +
+
+ @Html.DisplayNameFor(model => model.CodAutistaOld) +
+
+ @Html.DisplayFor(model => model.CodAutistaOld) +
+
+ @Html.DisplayNameFor(model => model.AutistaOld) +
+
+ @Html.DisplayFor(model => model.AutistaOld) +
+
+ @Html.DisplayNameFor(model => model.DescAutomezzoOld) +
+
+ @Html.DisplayFor(model => model.DescAutomezzoOld) +
+
+ + @Html.HiddenFor(model => model.DescAutomezzo) + @Html.HiddenFor(model => model.Brserial) + @Html.HiddenFor(model => model.DataCarico) + @Html.HiddenFor(model => model.CodCommittente) + @Html.HiddenFor(model => model.Committente) + @Html.HiddenFor(model => model.Autista) + + @Html.HiddenFor(model => model.CodSede) + @Html.HiddenFor(model => model.Sede) + @Html.HiddenFor(model => model.IndirizzoSede) + @Html.HiddenFor(model => model.Cproword) + @Html.HiddenFor(model => model.Cprownum) + @Html.HiddenFor(model => model.Brmerce) + @Html.HiddenFor(model => model.Brnote) + @Html.HiddenFor(model => model.ImportoDaRitirare) + @Html.HiddenFor(model => model.ItemList) + @Html.HiddenFor(model => model.serialeGiro) + @Html.HiddenFor(model => model.Casse) + @Html.HiddenFor(model => model.Trasf) + @Html.HiddenFor(model => model.Colli) + @Html.HiddenFor(model => model.num_cons) + @Html.HiddenFor(model => model.Uova) + @Html.HiddenFor(model => model.Cist) + @Html.HiddenFor(model => model.Note) + @Html.HiddenFor(model => model.Seq) + @Html.HiddenFor(model => model.Prog) + + @Html.HiddenFor(model => model.CodAutistaOld) + @Html.HiddenFor(model => model.CodAutomezzoOld) + @Html.HiddenFor(model => model.AutistaOld) + @Html.HiddenFor(model => model.DescAutomezzoOld) + + @Html.HiddenFor(model => model.CodAutista) + @Html.HiddenFor(model => model.CodAutomezzo) + +
+
+