From fb68e2461ec397bf5ef47e928dda9ecfed67f7b2 Mon Sep 17 00:00:00 2001 From: michele Date: Wed, 26 Jun 2024 12:54:14 +0200 Subject: [PATCH] Michele: DropdownList Giri --- Controllers/GiriController.cs | 15 ++++++--------- Views/Giri/Index.cshtml | 4 +++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Controllers/GiriController.cs b/Controllers/GiriController.cs index a589f1a..73f4985 100644 --- a/Controllers/GiriController.cs +++ b/Controllers/GiriController.cs @@ -31,7 +31,7 @@ namespace SoftwayWeb.Controllers { helper = new SessionHelper(this); token = helper.GetStringValue("tok"); - urlBase = apiUrl + "Giri/listaGiri?aperto="+aperto; + urlBase = apiUrl + "Giri/listaGiri?aperto="+ aperto; //string url = apiUrl + "Giri/listaGiri"; //urlBase = url + "?token=" + token; Uri baseAddress = new Uri(urlBase); @@ -46,11 +46,15 @@ namespace SoftwayWeb.Controllers string dato = response.Content.ReadAsStringAsync().Result; modelList = JsonConvert.DeserializeObject>(dato); + ViewBag.CodAutista = getAutisti(); + if (!string.IsNullOrEmpty(codAutista)) { modelList = modelList.Where(x => x.CodAutista.Contains(codAutista)).ToList(); ViewData["CurrentFilter"] = codAutista; + + //ViewBag.Autista = codAutista; } else { @@ -62,14 +66,6 @@ namespace SoftwayWeb.Controllers modelList = modelList.Where(x => x.DataGiro.GetValueOrDefault().Date == data.Date).ToList(); } - //if (aperto) - //{ - // modelList = modelList.Where(x => x.DataChiusura == null).ToList(); - //} - //else - //{ - // modelList = modelList.Where(x => x.DataChiusura != null).ToList(); - //} var shortList = modelList.ToPagedList(); return View(shortList/*modelList*/); } @@ -120,6 +116,7 @@ namespace SoftwayWeb.Controllers string e = helper.GetStringValue("errMsg"); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e }); } + private List getAutisti() { SessionHelper helper = new SessionHelper(this); diff --git a/Views/Giri/Index.cshtml b/Views/Giri/Index.cshtml index be0c7fe..a064496 100644 --- a/Views/Giri/Index.cshtml +++ b/Views/Giri/Index.cshtml @@ -26,7 +26,9 @@ @using (Html.BeginForm()) { -
@Html.TextBox("codAutista", null, new { placeholder = "Codice autista", @class = "agy-form-field require" })
+ @*
@Html.TextBox("codAutista", null, new { placeholder = "Codice autista", @class = "agy-form-field require" })
*@ +
@Html.DropDownList("codAutista", ViewBag.Autisti, null, new { @class = "agy-form-field require" })
+ @*
@Html.DropDownListFor(x => x., (IEnumerable)ViewBag.Autisti, new { @class = "agy-form-field require" })
*@
@Html.TextBox("data", null, new { type = "date", @class = "agy-form-field require" })