diff --git a/Controllers/AnagController.cs b/Controllers/AnagController.cs new file mode 100644 index 0000000..b331b92 --- /dev/null +++ b/Controllers/AnagController.cs @@ -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 modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(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); + } + } +} diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 1ed9745..b7ab25e 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -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() diff --git a/Controllers/LoginController.cs b/Controllers/LoginController.cs index 8cdb26d..f51dfe4 100644 --- a/Controllers/LoginController.cs +++ b/Controllers/LoginController.cs @@ -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() { diff --git a/Models/Anag.cs b/Models/Anag.cs new file mode 100644 index 0000000..bc3bc5d --- /dev/null +++ b/Models/Anag.cs @@ -0,0 +1,56 @@ +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; + +namespace VirtualTask.Models +{ + public class Anag + { + [Display(Name = "TIPO")] + /// tipo + public string? antipcon { get; set; } + + [Display(Name = "CODICE")] + /// codice + public string? ancodice { get; set; } + + [Display(Name = "EMAIL")] + /// email + public string? an_email { get; set; } + + [Display(Name = "CODICE FISCALE")] + /// codice fiscale + public string? ancodfis { get; set; } + + [Display(Name = "PARTITA IVA")] + /// partita iva + public string? anpariva { get; set; } + + [Display(Name = "INDIRIZZO")] + /// indirizzo + public string? anindiri { get; set; } + + [Display(Name = "TELEFONO")] + /// telefono + public string? antelefo { get; set; } + + [Display(Name = "CELLULARE")] + /// cellulare + public string? annumcel { get; set; } + + [Display(Name = "PEC")] + /// pec + public string? an_empec { get; set; } + + [Display(Name = "RAGIONE SOCIALE")] + /// descrizione + public string? andescri { get; set; } + + [Display(Name = "CODICE LISTINO")] + /// listino cliente + public string? annumlis { get; set; } + + [Display(Name = "DATA CANCELLAZIONE")] + /// cliente eliminato + public DateTime? andtobso { get; set; } + } +} diff --git a/Views/Anag/Index.cshtml b/Views/Anag/Index.cshtml new file mode 100644 index 0000000..77eb92c --- /dev/null +++ b/Views/Anag/Index.cshtml @@ -0,0 +1,132 @@ +@model IPagedList +@using X.PagedList; +@using X.PagedList.Mvc.Core; +@using X.PagedList.Web.Common; + + + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+@using (Html.BeginForm()) +{ +

+ Find by name: @Html.TextBox("SearchString") + +

+} + + + +@* *@ + + +@* *@ + + + @* + + + + + + + *@ + + + + +@foreach (var item in Model) { + +@* *@ + + +@* *@ + + + @* + + + + + + *@ + + +} + +
+ @Html.DisplayNameFor(model => model.antipcon) + + Codice + + Rag. Sociale + + @Html.DisplayNameFor(model => model.an_email) + + Codice Fiscale + + Partita Iva + + @Html.DisplayNameFor(model => model.anindiri) + + @Html.DisplayNameFor(model => model.antelefo) + + @Html.DisplayNameFor(model => model.annumcel) + + @Html.DisplayNameFor(model => model.an_empec) + + @Html.DisplayNameFor(model => model.annumlis) + + @Html.DisplayNameFor(model => model.andtobso) +
+ @Html.DisplayFor(modelItem => item.antipcon) + + @Html.DisplayFor(modelItem => item.ancodice) + + @Html.DisplayFor(modelItem => item.andescri) + + @Html.DisplayFor(modelItem => item.an_email) + + @Html.DisplayFor(modelItem => item.ancodfis) + + @Html.DisplayFor(modelItem => item.anpariva) + + @Html.DisplayFor(modelItem => item.anindiri) + + @Html.DisplayFor(modelItem => item.antelefo) + + @Html.DisplayFor(modelItem => item.annumcel) + + @Html.DisplayFor(modelItem => item.an_empec) + + @Html.DisplayFor(modelItem => item.annumlis) + + @Html.DisplayFor(modelItem => item.andtobso) + + @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) +
+
+ \ No newline at end of file diff --git a/Views/Login/Login.cshtml b/Views/Login/Login.cshtml index dd4f1c8..4853085 100644 --- a/Views/Login/Login.cshtml +++ b/Views/Login/Login.cshtml @@ -2,7 +2,7 @@ @{ ViewData["Title"] = "Login"; - Layout = null; + }

Login

diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml index 35ba84b..f161fca 100644 --- a/Views/Shared/_Layout.cshtml +++ b/Views/Shared/_Layout.cshtml @@ -25,6 +25,9 @@ + diff --git a/VirtualTask.csproj b/VirtualTask.csproj index 12fd5d6..6f8a94e 100644 --- a/VirtualTask.csproj +++ b/VirtualTask.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -9,6 +9,7 @@ +