diff --git a/Controllers/AziendaRifController.cs b/Controllers/AziendaRifController.cs index e022c7f..e329a07 100644 --- a/Controllers/AziendaRifController.cs +++ b/Controllers/AziendaRifController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; using Newtonsoft.Json; using System.Diagnostics; using System.Text; @@ -101,6 +102,7 @@ namespace VirtualTask.Controllers SessionHelper helper = new SessionHelper(this); admin = helper.GetStringValue("admin"); ViewBag.Admin = admin; + ViewBag.Impianti = getImpianti(); return View(); } @@ -219,6 +221,7 @@ namespace VirtualTask.Controllers return RedirectToAction("Error"); } + ViewBag.Impianti = getImpianti(); return View(aziRif); } @@ -335,6 +338,46 @@ namespace VirtualTask.Controllers #endregion DELETE + #region Metodi Interni + + private List getImpianti() + { + SessionHelper helper = new SessionHelper(this); + token = helper.GetStringValue("tok"); + apiUrl = helper.GetStringValue("apiUrl"); + urlBase = apiUrl + "impiantiListMngr"; + urlBase = urlBase + "?token=" + token; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + List selectItems = new List(); + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + + //per gestire primo elemento tendina (deve essere vuoto) + SelectListItem listItemFirt = new SelectListItem(); + + listItemFirt.Value = string.Empty; + listItemFirt.Text = " - Impianto"; + selectItems.Add(listItemFirt); + + foreach (var role in modelList) + { + SelectListItem listItem = new SelectListItem(); + string s = role.imcodimp + " - " + role.imdescri; + listItem.Value = role.imcodimp; + listItem.Text = s; + selectItems.Add(listItem); + } + } + + return selectItems; + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { @@ -343,5 +386,6 @@ namespace VirtualTask.Controllers return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e }); } + #endregion Metodi Interni } } diff --git a/Controllers/CommesseVTController.cs b/Controllers/CommesseVTController.cs index dccf2da..dc21ba7 100644 --- a/Controllers/CommesseVTController.cs +++ b/Controllers/CommesseVTController.cs @@ -192,6 +192,7 @@ namespace VirtualTask.Controllers return RedirectToAction("Error"); } + ViewBag.Impiabti = getImpianti(); return View(commessa); } @@ -212,14 +213,6 @@ namespace VirtualTask.Controllers client = new HttpClient(); client.BaseAddress = baseAddress; - - //ViewBag.Impianti = getImpianti(); - //ViewBag.Anag = getClienti(); - //urlBase = "http://10.0.0.187:8000/api/Polo" - //Uri baseAddress = new Uri(urlBase); - //client = new HttpClient(); - //client.BaseAddress = baseAddress; - CommesseVT_Table commessa = new CommesseVT_Table(); List modelList = new List(); @@ -520,8 +513,6 @@ namespace VirtualTask.Controllers return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e }); } - - #endregion #region CASCADING @@ -533,7 +524,6 @@ namespace VirtualTask.Controllers return View(model); } - [HttpPost] public ActionResult Cascading(string lacodcli) { diff --git a/Views/AziendaRif/Create.cshtml b/Views/AziendaRif/Create.cshtml index 6484e4c..4ba2878 100644 --- a/Views/AziendaRif/Create.cshtml +++ b/Views/AziendaRif/Create.cshtml @@ -15,14 +15,16 @@
-
- - + @*
*@ + @Html.HiddenFor(x => x.piazihoc) + @* *@ + @* *@
 
- + @* *@ + @Html.DropDownListFor(x => x.picodtec, (IEnumerable)ViewBag.Impianti, new { @class = "form-control" })
 
diff --git a/Views/AziendaRif/Edit.cshtml b/Views/AziendaRif/Edit.cshtml index afa2395..615765b 100644 --- a/Views/AziendaRif/Edit.cshtml +++ b/Views/AziendaRif/Edit.cshtml @@ -16,13 +16,15 @@
- - - + @* *@ + @Html.HiddenFor(x => x.piazihoc) + @* *@ + @* *@
- + @* *@ + @Html.DropDownListFor(x => x.picodtec, (IEnumerable)ViewBag.Impianti, new {@class = "form-control"})
diff --git a/Views/Chiamate/Index.cshtml b/Views/Chiamate/Index.cshtml index 4602b18..1554e33 100644 --- a/Views/Chiamate/Index.cshtml +++ b/Views/Chiamate/Index.cshtml @@ -29,7 +29,7 @@ - + @* *@ @@ -47,7 +47,8 @@ {
SerialeSerialeEsercizio Numero Data
- @Html.DisplayFor(modelItem => item.chserial) + @* @Html.DisplayFor(modelItem => item.chserial) *@ + @Html.HiddenFor(modelItem => item.chserial) @Html.DisplayFor(modelItem => item.chcodese) diff --git a/Views/CommesseVT/Edit.cshtml b/Views/CommesseVT/Edit.cshtml index 2a55da4..c90c8eb 100644 --- a/Views/CommesseVT/Edit.cshtml +++ b/Views/CommesseVT/Edit.cshtml @@ -34,7 +34,7 @@ -
+
@Html.HiddenFor(x => x.ladatchi) @* diff --git a/Views/Shared/_Layout2.cshtml b/Views/Shared/_Layout2.cshtml index 9154185..9c9a2c9 100644 --- a/Views/Shared/_Layout2.cshtml +++ b/Views/Shared/_Layout2.cshtml @@ -1,6 +1,5 @@ @{ string location = string.Empty; - // s = @"https://www.google.com/maps/dir/Polo+Informatico,+Via+Curio+Fornaci,+Terni,+TR/'45.59135,10.243048'/@43.7193823,8.2834344,7z/data=!3m1!4b1!4m11!4m10!1m5!1m1!1s0x132ee4b0d0b5464b:0xfe6f167f10da0915!2m2!1d12.612868!2d42.5681488!1m3!2m2!1d10.243048!2d45.59135?hl=it&entry=ttu"; location = @"https://www.google.com/maps/dir/Polo+Informatico,+Via+Curio+Fornaci,+Terni,+TR//@42.5682046,12.5716686,13z/data=!4m8!4m7!1m5!1m1!1s0x132ee4b0d0b5464b:0xfe6f167f10da0915!2m2!1d12.612868!2d42.5681488!1m0?hl=it&entry=ttu"; }