diff --git a/Controllers/ChiusureController.cs b/Controllers/ChiusureController.cs index eab3bdd..2e604fd 100644 --- a/Controllers/ChiusureController.cs +++ b/Controllers/ChiusureController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using System.Diagnostics; using System.Net; using System.Reflection; using System.Text; @@ -15,18 +16,10 @@ namespace VirtualTask.Controllers string urlBase = string.Empty; string token = string.Empty; string tenant = string.Empty; - //Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/codici_chiusura?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI"); + string errMes = string.Empty; HttpClient client; - //Uri baseAddressCreate = new Uri("http://10.0.0.187:8000/api/Polo/chiusure/add?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI"); - //HttpClient clientCreate; - - //Uri baseAddressEdit = new Uri("http://10.0.0.187:8000/api/Polo/chiusure/mod?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI"); - //HttpClient clientEdit; - - //Uri baseAddressDelete = new Uri("http://10.0.0.187:8000/api/Polo/chiusure/del?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI"); - //HttpClient clientDelete; - + public ChiusureController() { client = new HttpClient(); @@ -44,7 +37,7 @@ namespace VirtualTask.Controllers return RedirectToAction("Index", "Login"); apiUrl = helper.GetStringValue("apiUrl"); - urlBase = apiUrl + "codici_chiusura"; + urlBase = apiUrl + "chiusureVtList"; urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); @@ -57,28 +50,35 @@ namespace VirtualTask.Controllers { string data = response.Content.ReadAsStringAsync().Result; modelList = JsonConvert.DeserializeObject>(data); - } - if (!string.IsNullOrEmpty(searchString)) - { - modelList = modelList.Where(s => s.ccdescr.ToUpper().Contains(searchString.ToUpper())).ToList(); + if (!string.IsNullOrEmpty(searchString)) + { + modelList = modelList.Where(s => s.ccdescr.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.cccodice) + .ToPagedList(page ?? 1, pageSize); + + return View(shortLinks); } else - ViewData["CurrentFilter"] = null; - - if (page != null && page < 1) - { - page = 1; + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); } - var pageSize = 10; - - var shortLinks = modelList - .OrderByDescending(s => s.cccodice) - .ToPagedList(page ?? 1, pageSize); - - return View(shortLinks); } #endregion INDEX @@ -114,12 +114,19 @@ namespace VirtualTask.Controllers string data = JsonConvert.SerializeObject(model); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(baseAddress, content).Result; + if (response.IsSuccessStatusCode) { return RedirectToAction("Index"); } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + - return View(); } #endregion CREATE @@ -133,7 +140,7 @@ namespace VirtualTask.Controllers token = helper.GetStringValue("tok"); apiUrl = helper.GetStringValue("apiUrl"); - urlBase = apiUrl + "codici_chiusura"; + urlBase = apiUrl + "chiusureVtList"; urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); @@ -151,6 +158,12 @@ namespace VirtualTask.Controllers modelList = JsonConvert.DeserializeObject>(data); chiusura = modelList.Where(x => x.cccodice.Equals(id)).First(); } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } return View(chiusura); } @@ -166,7 +179,7 @@ namespace VirtualTask.Controllers token = helper.GetStringValue("tok"); apiUrl = helper.GetStringValue("apiUrl"); - urlBase = apiUrl + "codici_chiusura"; + urlBase = apiUrl + "chiusureVtList"; urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); @@ -185,6 +198,12 @@ namespace VirtualTask.Controllers var el = modelList.Where(t => t.cccodice.Equals(id)).First(); ele = el; } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } return View(ele); } @@ -215,7 +234,12 @@ namespace VirtualTask.Controllers { return RedirectToAction("Index"); } - return View(model); + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } } #endregion EDIT @@ -230,7 +254,7 @@ namespace VirtualTask.Controllers token = helper.GetStringValue("tok"); apiUrl = helper.GetStringValue("apiUrl"); - urlBase = apiUrl + "codici_chiusura"; + urlBase = apiUrl + "chiusureVtList"; urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); @@ -245,9 +269,14 @@ namespace VirtualTask.Controllers string data = response.Content.ReadAsStringAsync().Result; modelList = JsonConvert.DeserializeObject>(data); elem = modelList.Where(t => t.cccodice.Equals(id)).First(); + return View(elem); } - - return View(elem); + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } } [HttpPost, ActionName("DeleteConfirmed")] @@ -273,11 +302,22 @@ namespace VirtualTask.Controllers { return RedirectToAction("Index"); } - - return View(); - + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } } #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/Controllers/HomeController.cs b/Controllers/HomeController.cs index 33a114e..41b0180 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -25,21 +25,6 @@ namespace VirtualTask.Controllers } else { - //List modelList = new List(); - //Anag a=new Anag(); - //a.ancodice = "0001"; - //a.andescri = "Francesco Totti"; - //modelList.Add(a); - - //Anag b = new Anag(); - //b.ancodice = "0002"; - //b.andescri = "Alex Del Piero"; - //modelList.Add(b); - - - //SelectList customers = new SelectList(modelList,"ancodice","andescri"); - //ViewBag.Token = token; - //return View(customers); return View(); } } diff --git a/Controllers/LoginController.cs b/Controllers/LoginController.cs index 4f655d1..fd9d687 100644 --- a/Controllers/LoginController.cs +++ b/Controllers/LoginController.cs @@ -29,7 +29,7 @@ namespace VirtualTask.Controllers [HttpPost] public IActionResult Login(Login model) { - string url = apiUrl + "loginTechnical"; + string url = apiUrl + "loginTechnicalVT"; Uri baseAddress = new Uri(url); client.BaseAddress = baseAddress; diff --git a/Models/Chiusure.cs b/Models/Chiusure.cs index 0e77540..1f96e16 100644 --- a/Models/Chiusure.cs +++ b/Models/Chiusure.cs @@ -68,7 +68,6 @@ namespace VirtualTask.Models /// public string? ccriapre { get; set; } - /// public string? ccchiint { get; set; } } } diff --git a/Models/ErrorViewModel.cs b/Models/ErrorViewModel.cs index 5506933..7cd673d 100644 --- a/Models/ErrorViewModel.cs +++ b/Models/ErrorViewModel.cs @@ -5,5 +5,7 @@ namespace VirtualTask.Models public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + public string? ErrMsg { get; set; } } } \ No newline at end of file diff --git a/Views/Chiusure/Create.cshtml b/Views/Chiusure/Create.cshtml index e60cef7..b60cb04 100644 --- a/Views/Chiusure/Create.cshtml +++ b/Views/Chiusure/Create.cshtml @@ -12,12 +12,8 @@
- @*
- - - -
*@ - @Html.HiddenFor(x => x.cccodazi) + +
@@ -33,86 +29,26 @@
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
+ + @Html.HiddenFor(x => x.cccodazi) + @Html.HiddenFor(x => x.ccflfatt) + @Html.HiddenFor(x => x.ccflrep) + @Html.HiddenFor(x => x.cctipcod) + @Html.HiddenFor(x => x.ccgruppo) + @Html.HiddenFor(x => x.ccimpint) + @Html.HiddenFor(x => x.ccimpman) + @Html.HiddenFor(x => x.ccserint) + @Html.HiddenFor(x => x.ccserman) + @Html.HiddenFor(x => x.ccnumore) + @Html.HiddenFor(x => x.ccperman) + @Html.HiddenFor(x => x.corecom) + @Html.HiddenFor(x => x.codtobso) + @Html.HiddenFor(x => x.ccriapre) + @Html.HiddenFor(x => x.ccchiint) + @Html.HiddenFor(x => x.ccrapabi) + @Html.HiddenFor(x => x.ccrapobb) + +
diff --git a/Views/Chiusure/Delete.cshtml b/Views/Chiusure/Delete.cshtml index cc20237..82c7db5 100644 --- a/Views/Chiusure/Delete.cshtml +++ b/Views/Chiusure/Delete.cshtml @@ -35,102 +35,6 @@
@Html.DisplayFor(model => model.ccdessup)
-
- @Html.DisplayNameFor(model => model.ccflfatt) -
-
- @Html.DisplayFor(model => model.ccflfatt) -
-
- @Html.DisplayNameFor(model => model.ccflrep) -
-
- @Html.DisplayFor(model => model.ccflrep) -
-
- @Html.DisplayNameFor(model => model.cctipcod) -
-
- @Html.DisplayFor(model => model.cctipcod) -
-
- @Html.DisplayNameFor(model => model.ccgruppo) -
-
- @Html.DisplayFor(model => model.ccgruppo) -
-
- @Html.DisplayNameFor(model => model.ccimpint) -
-
- @Html.DisplayFor(model => model.ccimpint) -
-
- @Html.DisplayNameFor(model => model.ccimpman) -
-
- @Html.DisplayFor(model => model.ccimpman) -
-
- @Html.DisplayNameFor(model => model.ccserint) -
-
- @Html.DisplayFor(model => model.ccserint) -
-
- @Html.DisplayNameFor(model => model.ccserman) -
-
- @Html.DisplayFor(model => model.ccserman) -
-
- @Html.DisplayNameFor(model => model.ccnumore) -
-
- @Html.DisplayFor(model => model.ccnumore) -
-
- @Html.DisplayNameFor(model => model.ccperman) -
-
- @Html.DisplayFor(model => model.ccperman) -
-
- @Html.DisplayNameFor(model => model.corecom) -
-
- @Html.DisplayFor(model => model.corecom) -
-
- @Html.DisplayNameFor(model => model.codtobso) -
-
- @Html.DisplayFor(model => model.codtobso) -
-
- @Html.DisplayNameFor(model => model.ccrapabi) -
-
- @Html.DisplayFor(model => model.ccrapabi) -
-
- @Html.DisplayNameFor(model => model.ccrapobb) -
-
- @Html.DisplayFor(model => model.ccrapobb) -
-
- @Html.DisplayNameFor(model => model.ccriapre) -
-
- @Html.DisplayFor(model => model.ccriapre) -
-
- @Html.DisplayNameFor(model => model.ccchiint) -
-
- @Html.DisplayFor(model => model.ccchiint) -
diff --git a/Views/Chiusure/Details.cshtml b/Views/Chiusure/Details.cshtml index 666ead7..b2e8324 100644 --- a/Views/Chiusure/Details.cshtml +++ b/Views/Chiusure/Details.cshtml @@ -34,105 +34,8 @@
@Html.DisplayFor(model => model.ccdessup)
-
- @Html.DisplayNameFor(model => model.ccflfatt) -
-
- @Html.DisplayFor(model => model.ccflfatt) -
-
- @Html.DisplayNameFor(model => model.ccflrep) -
-
- @Html.DisplayFor(model => model.ccflrep) -
-
- @Html.DisplayNameFor(model => model.cctipcod) -
-
- @Html.DisplayFor(model => model.cctipcod) -
-
- @Html.DisplayNameFor(model => model.ccgruppo) -
-
- @Html.DisplayFor(model => model.ccgruppo) -
-
- @Html.DisplayNameFor(model => model.ccimpint) -
-
- @Html.DisplayFor(model => model.ccimpint) -
-
- @Html.DisplayNameFor(model => model.ccimpman) -
-
- @Html.DisplayFor(model => model.ccimpman) -
-
- @Html.DisplayNameFor(model => model.ccserint) -
-
- @Html.DisplayFor(model => model.ccserint) -
-
- @Html.DisplayNameFor(model => model.ccserman) -
-
- @Html.DisplayFor(model => model.ccserman) -
-
- @Html.DisplayNameFor(model => model.ccnumore) -
-
- @Html.DisplayFor(model => model.ccnumore) -
-
- @Html.DisplayNameFor(model => model.ccperman) -
-
- @Html.DisplayFor(model => model.ccperman) -
-
- @Html.DisplayNameFor(model => model.corecom) -
-
- @Html.DisplayFor(model => model.corecom) -
-
- @Html.DisplayNameFor(model => model.codtobso) -
-
- @Html.DisplayFor(model => model.codtobso) -
-
- @Html.DisplayNameFor(model => model.ccrapabi) -
-
- @Html.DisplayFor(model => model.ccrapabi) -
-
- @Html.DisplayNameFor(model => model.ccrapobb) -
-
- @Html.DisplayFor(model => model.ccrapobb) -
-
- @Html.DisplayNameFor(model => model.ccriapre) -
-
- @Html.DisplayFor(model => model.ccriapre) -
-
- @Html.DisplayNameFor(model => model.ccchiint) -
-
- @Html.DisplayFor(model => model.ccchiint) -
- @Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) | Back to List
diff --git a/Views/Chiusure/Edit.cshtml b/Views/Chiusure/Edit.cshtml index 545d98c..b5f906b 100644 --- a/Views/Chiusure/Edit.cshtml +++ b/Views/Chiusure/Edit.cshtml @@ -12,12 +12,7 @@
- @*
- - - -
*@ - @Html.HiddenFor(x => x.cccodazi) +
@@ -33,86 +28,23 @@
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
+ @Html.HiddenFor(x => x.cccodazi) + @Html.HiddenFor(x => x.ccflfatt) + @Html.HiddenFor(x => x.ccflrep) + @Html.HiddenFor(x => x.cctipcod) + @Html.HiddenFor(x => x.ccgruppo) + @Html.HiddenFor(x => x.ccimpint) + @Html.HiddenFor(x => x.ccimpman) + @Html.HiddenFor(x => x.ccserint) + @Html.HiddenFor(x => x.ccserman) + @Html.HiddenFor(x => x.ccnumore) + @Html.HiddenFor(x => x.ccperman) + @Html.HiddenFor(x => x.corecom) + @Html.HiddenFor(x => x.codtobso) + @Html.HiddenFor(x => x.ccriapre) + @Html.HiddenFor(x => x.ccchiint) + @Html.HiddenFor(x => x.ccrapabi) + @Html.HiddenFor(x => x.ccrapobb)
diff --git a/Views/Shared/Error.cshtml b/Views/Shared/Error.cshtml index a1e0478..f929d94 100644 --- a/Views/Shared/Error.cshtml +++ b/Views/Shared/Error.cshtml @@ -11,6 +11,9 @@

Request ID: @Model.RequestId

+

+ Error: @Model.ErrMsg +

}

Development Mode