diff --git a/Controllers/AnagController.cs b/Controllers/AnagController.cs index 2a90630..4c836ee 100644 --- a/Controllers/AnagController.cs +++ b/Controllers/AnagController.cs @@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using NuGet.Common; +using System.Diagnostics; +using System.Reflection; using System.Runtime.Intrinsics.Arm; using System.Text; using VirtualTask.Models; @@ -14,13 +16,13 @@ namespace VirtualTask.Controllers string apiUrl = string.Empty; string urlBase=string.Empty; string token=string.Empty; - //Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/anagraficheList?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI"); - //Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/anagraficheList?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI"); + string tenant = string.Empty; + string errMes = string.Empty; HttpClient client; public AnagController() - { - + { + client = new HttpClient(); } #region INDEX @@ -36,7 +38,6 @@ namespace VirtualTask.Controllers urlBase = apiUrl+"anagraficheList"; urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); - client = new HttpClient(); client.BaseAddress = baseAddress; List modelList = new List(); @@ -46,31 +47,38 @@ namespace VirtualTask.Controllers { 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 (!string.IsNullOrEmpty(searchString)) - { - modelList = modelList.Where(s => s.andescri.ToUpper().Contains(searchString.ToUpper())).ToList(); - - ViewData["CurrentFilter"] = searchString; + 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); } else { - ViewData["CurrentFilter"] = null; + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); } - if (page != null && page < 1) - { - page = 1; - } - var pageSize = 10; - - var shortLinks = modelList - .OrderByDescending(s => s.ancodice) - .ToPagedList(page ?? 1, pageSize); - - return View(shortLinks); } #endregion INDEX @@ -88,7 +96,8 @@ namespace VirtualTask.Controllers SessionHelper helper = new SessionHelper(this); token = helper.GetStringValue("tok"); - + tenant = helper.GetStringValue("tenant"); + model.ancodazi=tenant; apiUrl = helper.GetStringValue("apiUrl"); urlBase = apiUrl + "anagrafiche/add"; urlBase = urlBase + "?token=" + token; @@ -103,8 +112,13 @@ namespace VirtualTask.Controllers { return RedirectToAction("Index"); } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } - return View(); } #endregion CREATE @@ -136,6 +150,12 @@ namespace VirtualTask.Controllers modelList = JsonConvert.DeserializeObject>(data); anag = modelList.Where(x => x.ancodice.Equals(id)).First(); } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } return View(anag); } @@ -168,7 +188,13 @@ namespace VirtualTask.Controllers string data = response.Content.ReadAsStringAsync().Result; modelList = JsonConvert.DeserializeObject>(data); anag = modelList.Where(x => x.ancodice.Equals(id)).First(); - + + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); } return View(anag); @@ -180,7 +206,8 @@ namespace VirtualTask.Controllers SessionHelper helper = new SessionHelper(this); token = helper.GetStringValue("tok"); - + tenant = helper.GetStringValue("tenant"); + model.ancodazi = tenant; apiUrl = helper.GetStringValue("apiUrl"); urlBase = apiUrl + "anagrafiche/mod"; urlBase = urlBase + "?token=" + token; @@ -198,8 +225,13 @@ namespace VirtualTask.Controllers { return RedirectToAction("Index"); } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } - return View(model); } #endregion EDIT @@ -238,20 +270,22 @@ namespace VirtualTask.Controllers //DA MODIFICARE PERCHE' NON E' UNA DELETE MA UN UPDATE DELLA DATA OBSOLESCENZA [HttpPost, ActionName("DeleteConfirmed")] - public IActionResult DeleteConfirmed(string id) + public IActionResult DeleteConfirmed(Anag model) { SessionHelper helper = new SessionHelper(this); token = helper.GetStringValue("tok"); - + tenant = helper.GetStringValue("tenant"); + model.ancodazi = tenant; + model.andtobso=DateTime.Now; apiUrl = helper.GetStringValue("apiUrl"); - urlBase = apiUrl + "anagrafiche/del?" + "codice=" + id + "&"; - urlBase = urlBase + "token=" + token; + urlBase = apiUrl + "anagrafiche/del"; + urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); client.BaseAddress = baseAddress; - string data = JsonConvert.SerializeObject(id); + string data = JsonConvert.SerializeObject(model); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); @@ -261,10 +295,23 @@ namespace VirtualTask.Controllers { return RedirectToAction("Index"); } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } - return View(); } #endregion DELETE + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + SessionHelper helper = new SessionHelper(this); + string e = helper.GetStringValue("errMsg"); + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e }); + } } } diff --git a/Models/Anag.cs b/Models/Anag.cs index bc3bc5d..15c7a0a 100644 --- a/Models/Anag.cs +++ b/Models/Anag.cs @@ -6,13 +6,17 @@ namespace VirtualTask.Models public class Anag { [Display(Name = "TIPO")] - /// tipo + /// tipo (chiave) public string? antipcon { get; set; } [Display(Name = "CODICE")] - /// codice + /// codice (chiave) public string? ancodice { get; set; } + [Display(Name = "AZIENDA")] + /// aziewnda (chiave) + public string? ancodazi { get; set; } + [Display(Name = "EMAIL")] /// email public string? an_email { get; set; } diff --git a/Views/Anag/Create.cshtml b/Views/Anag/Create.cshtml index b8e3e01..9d34116 100644 --- a/Views/Anag/Create.cshtml +++ b/Views/Anag/Create.cshtml @@ -12,21 +12,21 @@
-
- - - -
+ + @Html.HiddenFor(x => x.andtobso) + @Html.HiddenFor(x => x.annumlis) +
- - - + + +
+
@@ -52,26 +52,18 @@
+
+ + + +
-
- - - -
-
- - - -
-
- - - -
+ +
diff --git a/Views/Anag/Delete.cshtml b/Views/Anag/Delete.cshtml index e0c13a5..3ca0ed6 100644 --- a/Views/Anag/Delete.cshtml +++ b/Views/Anag/Delete.cshtml @@ -16,51 +16,61 @@
@Html.DisplayFor(model => model.antipcon) +
@Html.DisplayNameFor(model => model.ancodice)
@Html.DisplayFor(model => model.ancodice) +
@Html.DisplayNameFor(model => model.an_email) +
@Html.DisplayFor(model => model.an_email) +
@Html.DisplayNameFor(model => model.ancodfis)
@Html.DisplayFor(model => model.ancodfis) +
@Html.DisplayNameFor(model => model.anpariva)
@Html.DisplayFor(model => model.anpariva) +
@Html.DisplayNameFor(model => model.anindiri)
@Html.DisplayFor(model => model.anindiri) +
@Html.DisplayNameFor(model => model.antelefo)
@Html.DisplayFor(model => model.antelefo) +
@Html.DisplayNameFor(model => model.annumcel)
@Html.DisplayFor(model => model.annumcel) +
@Html.DisplayNameFor(model => model.an_empec) +
@Html.DisplayFor(model => model.an_empec) @@ -70,24 +80,25 @@
@Html.DisplayFor(model => model.andescri) +
-
- @Html.DisplayNameFor(model => model.annumlis) -
-
- @Html.DisplayFor(model => model.annumlis) -
-
- @Html.DisplayNameFor(model => model.andtobso) -
-
- @Html.DisplayFor(model => model.andtobso) -
+ + + @Html.HiddenFor(x => x.annumlis) + @Html.HiddenFor(x => x.andescri) + @Html.HiddenFor(x => x.an_empec) + @Html.HiddenFor(x => x.annumcel) + @Html.HiddenFor(x => x.antelefo) + @Html.HiddenFor(x => x.anindiri) + @Html.HiddenFor(x => x.anpariva) + @Html.HiddenFor(x => x.ancodfis) + @Html.HiddenFor(x => x.an_email) + @Html.HiddenFor(x => x.ancodice) + @Html.HiddenFor(x => x.antipcon) | - model.ancodice) name="id" /> Back to List
diff --git a/Views/Anag/Details.cshtml b/Views/Anag/Details.cshtml index dfe0fa3..7ef36a4 100644 --- a/Views/Anag/Details.cshtml +++ b/Views/Anag/Details.cshtml @@ -10,24 +10,20 @@

Anag


-
- @Html.DisplayNameFor(model => model.antipcon) -
-
- @Html.DisplayFor(model => model.antipcon) -
+
@Html.DisplayNameFor(model => model.ancodice)
@Html.DisplayFor(model => model.ancodice)
-
- @Html.DisplayNameFor(model => model.an_email) +
+ @Html.DisplayNameFor(model => model.andescri)
-
- @Html.DisplayFor(model => model.an_email) +
+ @Html.DisplayFor(model => model.andescri)
+
@Html.DisplayNameFor(model => model.ancodfis)
@@ -58,30 +54,20 @@
@Html.DisplayFor(model => model.annumcel)
+
+ @Html.DisplayNameFor(model => model.an_email) +
+
+ @Html.DisplayFor(model => model.an_email) +
@Html.DisplayNameFor(model => model.an_empec)
@Html.DisplayFor(model => model.an_empec)
-
- @Html.DisplayNameFor(model => model.andescri) -
-
- @Html.DisplayFor(model => model.andescri) -
-
- @Html.DisplayNameFor(model => model.annumlis) -
-
- @Html.DisplayFor(model => model.annumlis) -
-
- @Html.DisplayNameFor(model => model.andtobso) -
-
- @Html.DisplayFor(model => model.andtobso) -
+ +
diff --git a/Views/Anag/Edit.cshtml b/Views/Anag/Edit.cshtml index ab7e7bd..ec4aef0 100644 --- a/Views/Anag/Edit.cshtml +++ b/Views/Anag/Edit.cshtml @@ -12,21 +12,21 @@
-
- - - -
+ + @Html.HiddenFor(x => x.antipcon) + @Html.HiddenFor(x => x.andtobso) + @Html.HiddenFor(x => x.annumlis)
- - - + + +
+
@@ -52,26 +52,19 @@
+
+ + + +
-
- - - -
-
- - - -
-
- - - -
+ + +