Michele: Paginazione destinazioni tramite helper

This commit is contained in:
michele 2024-07-09 17:26:13 +02:00
parent b9ab52911e
commit 1907f4e704
2 changed files with 29 additions and 48 deletions

View File

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using SoftwayWeb.Models;
using System.Text;
using X.PagedList;
namespace SoftwayWeb.Controllers
@ -28,38 +29,43 @@ namespace SoftwayWeb.Controllers
{
helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
//StringBuilder aut = new StringBuilder();
string autista = string.Empty;
string dataGi = string.Empty;
string mezzo = string.Empty;
if (!string.IsNullOrEmpty(codAutista))
{
helper.SetStringValue("codAutista", codAutista);
}
else
{
string s = helper.GetStringValue("codAutista");
string aut = helper.GetStringValue("codAutista");
codAutista = aut;
}
ViewBag.CodAutista = codAutista;
//if (codAutista == null)
//{
// //ViewBag.CodAutista = "codAutista";
// codAutista = ViewBag.CodAutista;
//}
//if (!string.IsNullOrEmpty(codAutista))
//{
// //modelList = modelList.Where(x => x.CodAutista.Contains(codAutista)).ToList();
// ViewData["CurrentFilter"] = codAutista;
// ViewBag.Autista = codAutista;
//}
//else
//{
// ViewData = ViewBag.CodAutista;
//}
if (!string.IsNullOrEmpty(codMezzo))
{
helper.SetStringValue("codMezzo", codMezzo.ToString());
}
else
{
string mez = helper.GetStringValue("codMezzo");
codMezzo = mez;
}
if (dataGiro.Date != DateTime.MinValue)
{
helper.SetStringValue("dataGiro", dataGiro.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'"));
dataGi = dataGiro.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'");
}
else
{
dataGi = helper.GetStringValue("dataGiro");
}
urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzo";
string dataGi = dataGiro.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'");
urlBase = urlBase + "?autista=" + codAutista.TrimEnd() + "&dataGiro=" + dataGi + "&mezzo=" + codMezzo;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
@ -74,12 +80,6 @@ namespace SoftwayWeb.Controllers
modelList = JsonConvert.DeserializeObject<List<Destinazioni_Out>>(dato);
modelList = modelList.Where(x => x.serialeGiro == id).ToList();
//ViewData["codAutista"] = codAutista;
//ViewBag.CodAutista = "codAutista";
//ViewBag.DataGiro = dataGiro;
//ViewBag.CodMezzo = codMezzo;
if (page != null && page < 1)
{
page = 1;
@ -87,7 +87,7 @@ namespace SoftwayWeb.Controllers
var pageSize = 10;
var shortList = modelList.ToPagedList(page ?? 1, pageSize);
return View(/*modelList*/shortList);
return View(shortList);
}
else
{
@ -96,8 +96,6 @@ namespace SoftwayWeb.Controllers
return RedirectToAction("Error");
}
//var shortList = modelList.ToPagedList();
//return View(shortList);
}
}
}

View File

@ -12,11 +12,6 @@
<h1>Lista destinazioni</h1>
<h2>@ViewBag.CodAutista</h2>
@* <p>
<a asp-action="Create">Create New</a>
</p>
@ -208,18 +203,6 @@
<td hidden>
@Html.HiddenFor(modelItem => item.ItemList)
</td>
@* @if (item.ConsFatta != null){
<td>
<img alt="cons" src="@Url.Content("~/images/fatto1.png")" style="width:35px;height:35px;">
</td>
} *@
@* @if (item.ConsFatta == null)
{
<td>
<img alt="nocons" src="@Url.Content("~/images/Yellow.png")" style="width:50px;height:50px;">
</td>
} *@
@* <td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |