Controller anagrafiche, lista , ricerca e paginazione
This commit is contained in:
parent
f8aab56606
commit
c14812194a
59
Controllers/AnagController.cs
Normal file
59
Controllers/AnagController.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using VirtualTask.Models;
|
||||
using X.PagedList;
|
||||
|
||||
namespace VirtualTask.Controllers
|
||||
{
|
||||
public class AnagController : Controller
|
||||
{
|
||||
Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/anagraficheList?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
|
||||
HttpClient client;
|
||||
public AnagController()
|
||||
{
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IActionResult Index(string searchString, int? page = 1)
|
||||
{
|
||||
//string lastSearch=string.Empty;
|
||||
//lastSearch = (string)ViewData["CurrentFilter"];
|
||||
|
||||
List<Anag> modelList = new List<Anag>();
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
modelList = JsonConvert.DeserializeObject<List<Anag>>(data);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
modelList = modelList.Where(s => s.andescri.ToUpper().Contains(searchString.ToUpper())).ToList();
|
||||
|
||||
//if(lastSearch!= searchString)
|
||||
// page = 1;
|
||||
ViewData["CurrentFilter"] = searchString;
|
||||
}
|
||||
else
|
||||
ViewData["CurrentFilter"] = null;
|
||||
|
||||
if (page != null && page < 1)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
|
||||
var pageSize = 10;
|
||||
|
||||
var shortLinks = modelList
|
||||
.OrderByDescending(s => s.ancodice)
|
||||
.ToPagedList(page ?? 1, pageSize);
|
||||
|
||||
return View(shortLinks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,12 +19,14 @@ namespace VirtualTask.Controllers
|
||||
if (!string.IsNullOrEmpty(t))
|
||||
{
|
||||
ViewBag.Token = t;
|
||||
|
||||
return View();
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewBag.Token = string.Empty;
|
||||
|
||||
return View();
|
||||
return RedirectToAction("Error", "Home");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
|
||||
@ -8,8 +8,8 @@ namespace VirtualTask.Controllers
|
||||
public class LoginController : Controller
|
||||
{
|
||||
|
||||
//https://localhost:7068/api/Polo/loginTechnical
|
||||
Uri baseAddress = new Uri("http://10.0.0.187:5068/api/Polo/loginTechnical");
|
||||
|
||||
Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/loginTechnical");
|
||||
HttpClient client;
|
||||
public LoginController()
|
||||
{
|
||||
|
||||
56
Models/Anag.cs
Normal file
56
Models/Anag.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace VirtualTask.Models
|
||||
{
|
||||
public class Anag
|
||||
{
|
||||
[Display(Name = "TIPO")]
|
||||
/// <summary>tipo </summary>
|
||||
public string? antipcon { get; set; }
|
||||
|
||||
[Display(Name = "CODICE")]
|
||||
/// <summary>codice</summary>
|
||||
public string? ancodice { get; set; }
|
||||
|
||||
[Display(Name = "EMAIL")]
|
||||
/// <summary>email</summary>
|
||||
public string? an_email { get; set; }
|
||||
|
||||
[Display(Name = "CODICE FISCALE")]
|
||||
/// <summary>codice fiscale</summary>
|
||||
public string? ancodfis { get; set; }
|
||||
|
||||
[Display(Name = "PARTITA IVA")]
|
||||
/// <summary>partita iva</summary>
|
||||
public string? anpariva { get; set; }
|
||||
|
||||
[Display(Name = "INDIRIZZO")]
|
||||
/// <summary>indirizzo</summary>
|
||||
public string? anindiri { get; set; }
|
||||
|
||||
[Display(Name = "TELEFONO")]
|
||||
/// <summary>telefono</summary>
|
||||
public string? antelefo { get; set; }
|
||||
|
||||
[Display(Name = "CELLULARE")]
|
||||
/// <summary>cellulare</summary>
|
||||
public string? annumcel { get; set; }
|
||||
|
||||
[Display(Name = "PEC")]
|
||||
/// <summary>pec</summary>
|
||||
public string? an_empec { get; set; }
|
||||
|
||||
[Display(Name = "RAGIONE SOCIALE")]
|
||||
/// <summary>descrizione </summary>
|
||||
public string? andescri { get; set; }
|
||||
|
||||
[Display(Name = "CODICE LISTINO")]
|
||||
/// <summary>listino cliente </summary>
|
||||
public string? annumlis { get; set; }
|
||||
|
||||
[Display(Name = "DATA CANCELLAZIONE")]
|
||||
/// <summary> cliente eliminato </summary>
|
||||
public DateTime? andtobso { get; set; }
|
||||
}
|
||||
}
|
||||
132
Views/Anag/Index.cshtml
Normal file
132
Views/Anag/Index.cshtml
Normal file
@ -0,0 +1,132 @@
|
||||
@model IPagedList<VirtualTask.Models.Anag>
|
||||
@using X.PagedList;
|
||||
@using X.PagedList.Mvc.Core;
|
||||
@using X.PagedList.Web.Common;
|
||||
|
||||
|
||||
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Index</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
<p>
|
||||
Find by name: @Html.TextBox("SearchString")
|
||||
<input type="submit" value="Search" />
|
||||
</p>
|
||||
}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@* <th>
|
||||
@Html.DisplayNameFor(model => model.antipcon)
|
||||
</th>*@
|
||||
<th>
|
||||
Codice
|
||||
</th>
|
||||
<th>
|
||||
Rag. Sociale
|
||||
</th>
|
||||
@* <th>
|
||||
@Html.DisplayNameFor(model => model.an_email)
|
||||
</th>*@
|
||||
<th>
|
||||
Codice Fiscale
|
||||
</th>
|
||||
<th>
|
||||
Partita Iva
|
||||
</th>
|
||||
@*
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.anindiri)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.antelefo)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.annumcel)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.an_empec)
|
||||
</th>
|
||||
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.annumlis)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.andtobso)
|
||||
</th>*@
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
@* <td>
|
||||
@Html.DisplayFor(modelItem => item.antipcon)
|
||||
</td>*@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ancodice)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.andescri)
|
||||
</td>
|
||||
@* <td>
|
||||
@Html.DisplayFor(modelItem => item.an_email)
|
||||
</td>*@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ancodfis)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.anpariva)
|
||||
</td>
|
||||
@* <td>
|
||||
@Html.DisplayFor(modelItem => item.anindiri)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.antelefo)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.annumcel)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.an_empec)
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.annumlis)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.andtobso)
|
||||
</td>*@
|
||||
<td>
|
||||
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
|
||||
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
|
||||
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<nav>
|
||||
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, searchString=@ViewData["CurrentFilter"] }), new PagedListRenderOptions()
|
||||
{
|
||||
ActiveLiElementClass = "active",
|
||||
PageClasses = new[]{ "page-link"},
|
||||
LiElementClasses=new[] { "page-item" },
|
||||
UlElementClasses = new[] { "pagination","justify-content-center", "mt-3" },
|
||||
LinkToNextPageFormat = "Next",
|
||||
LinkToPreviousPageFormat = "Previous",
|
||||
MaximumPageNumbersToDisplay = 5,
|
||||
DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
|
||||
DisplayLinkToNextPage = PagedListDisplayMode.Always
|
||||
|
||||
})
|
||||
</nav>
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Login";
|
||||
Layout = null;
|
||||
|
||||
}
|
||||
|
||||
<h1>Login</h1>
|
||||
|
||||
@ -25,6 +25,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Chiusure" asp-action="Index">COD. CHIUSURA</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Anag" asp-action="Index">ANAGRAFICHE</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -9,6 +9,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="X.PagedList.Mvc.Core" Version="8.4.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user