Michele: Paginazione destinazioni tramite helper
This commit is contained in:
parent
b9ab52911e
commit
1907f4e704
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SoftwayWeb.Models;
|
using SoftwayWeb.Models;
|
||||||
|
using System.Text;
|
||||||
using X.PagedList;
|
using X.PagedList;
|
||||||
|
|
||||||
namespace SoftwayWeb.Controllers
|
namespace SoftwayWeb.Controllers
|
||||||
@ -28,38 +29,43 @@ namespace SoftwayWeb.Controllers
|
|||||||
{
|
{
|
||||||
helper = new SessionHelper(this);
|
helper = new SessionHelper(this);
|
||||||
token = helper.GetStringValue("tok");
|
token = helper.GetStringValue("tok");
|
||||||
|
|
||||||
|
//StringBuilder aut = new StringBuilder();
|
||||||
|
string autista = string.Empty;
|
||||||
|
string dataGi = string.Empty;
|
||||||
|
string mezzo = string.Empty;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(codAutista))
|
if (!string.IsNullOrEmpty(codAutista))
|
||||||
{
|
{
|
||||||
helper.SetStringValue("codAutista", codAutista);
|
helper.SetStringValue("codAutista", codAutista);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string s = helper.GetStringValue("codAutista");
|
string aut = helper.GetStringValue("codAutista");
|
||||||
|
codAutista = aut;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewBag.CodAutista = codAutista;
|
if (!string.IsNullOrEmpty(codMezzo))
|
||||||
//if (codAutista == null)
|
{
|
||||||
//{
|
helper.SetStringValue("codMezzo", codMezzo.ToString());
|
||||||
// //ViewBag.CodAutista = "codAutista";
|
}
|
||||||
// codAutista = ViewBag.CodAutista;
|
else
|
||||||
//}
|
{
|
||||||
|
string mez = helper.GetStringValue("codMezzo");
|
||||||
|
codMezzo = mez;
|
||||||
//if (!string.IsNullOrEmpty(codAutista))
|
}
|
||||||
//{
|
|
||||||
// //modelList = modelList.Where(x => x.CodAutista.Contains(codAutista)).ToList();
|
|
||||||
|
|
||||||
// ViewData["CurrentFilter"] = codAutista;
|
|
||||||
|
|
||||||
// ViewBag.Autista = codAutista;
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// ViewData = ViewBag.CodAutista;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
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";
|
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;
|
urlBase = urlBase + "?autista=" + codAutista.TrimEnd() + "&dataGiro=" + dataGi + "&mezzo=" + codMezzo;
|
||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
@ -74,12 +80,6 @@ namespace SoftwayWeb.Controllers
|
|||||||
modelList = JsonConvert.DeserializeObject<List<Destinazioni_Out>>(dato);
|
modelList = JsonConvert.DeserializeObject<List<Destinazioni_Out>>(dato);
|
||||||
modelList = modelList.Where(x => x.serialeGiro == id).ToList();
|
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)
|
if (page != null && page < 1)
|
||||||
{
|
{
|
||||||
page = 1;
|
page = 1;
|
||||||
@ -87,7 +87,7 @@ namespace SoftwayWeb.Controllers
|
|||||||
var pageSize = 10;
|
var pageSize = 10;
|
||||||
|
|
||||||
var shortList = modelList.ToPagedList(page ?? 1, pageSize);
|
var shortList = modelList.ToPagedList(page ?? 1, pageSize);
|
||||||
return View(/*modelList*/shortList);
|
return View(shortList);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -96,8 +96,6 @@ namespace SoftwayWeb.Controllers
|
|||||||
return RedirectToAction("Error");
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
//var shortList = modelList.ToPagedList();
|
|
||||||
//return View(shortList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,11 +12,6 @@
|
|||||||
|
|
||||||
<h1>Lista destinazioni</h1>
|
<h1>Lista destinazioni</h1>
|
||||||
|
|
||||||
|
|
||||||
<h2>@ViewBag.CodAutista</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@* <p>
|
@* <p>
|
||||||
<a asp-action="Create">Create New</a>
|
<a asp-action="Create">Create New</a>
|
||||||
</p>
|
</p>
|
||||||
@ -208,18 +203,6 @@
|
|||||||
<td hidden>
|
<td hidden>
|
||||||
@Html.HiddenFor(modelItem => item.ItemList)
|
@Html.HiddenFor(modelItem => item.ItemList)
|
||||||
</td>
|
</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>
|
@* <td>
|
||||||
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
|
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
|
||||||
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
|
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user