diff --git a/Controllers/GiriController.cs b/Controllers/GiriController.cs index 038fd95..4f40801 100644 --- a/Controllers/GiriController.cs +++ b/Controllers/GiriController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.Rendering; using Newtonsoft.Json; using SoftwayWeb.Models; +using System.Collections.Generic; using System.Diagnostics; using System.Runtime.Intrinsics.Arm; using System.Text; @@ -146,6 +147,63 @@ namespace SoftwayWeb.Controllers return RedirectToAction("Index", "Giri"); } + public IActionResult Bancali(string id, bool aperto = true) + { + SessionHelper helper = new SessionHelper(this); + + apiUrl = helper.GetStringValue("apiUrl"); + urlBase = apiUrl + "Giri/listaGiri?aperto=" + aperto; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + List modelList = new List(); + GiriConsegnaView model = new GiriConsegnaView(); + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + model = modelList.Where(x => x.SerialeGiro.Equals(id)).First(); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + + return View(model); + } + + [HttpPost] + public IActionResult Bancali(GiriConsegnaView model) + { + SessionHelper helper = new SessionHelper(this); + apiUrl = helper.GetStringValue("apiUrl"); + urlBase = apiUrl + "Giri/modGiro"; + + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + 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", "Giri"); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + } + //[HttpPost] //public IActionResult Create(GiriConsegnaView model) //{ diff --git a/SoftwayWeb.csproj b/SoftwayWeb.csproj index 7f6cc1f..5ec5331 100644 --- a/SoftwayWeb.csproj +++ b/SoftwayWeb.csproj @@ -7,7 +7,7 @@ - + diff --git a/Views/Giri/Bancali.cshtml b/Views/Giri/Bancali.cshtml new file mode 100644 index 0000000..c460ff0 --- /dev/null +++ b/Views/Giri/Bancali.cshtml @@ -0,0 +1,111 @@ +@model SoftwayWeb.Models.GiriConsegnaView + +@{ + ViewData["Title"] = "Bancali"; +} + +

Modifica numero Bancali

+ +@*

GiriConsegnaView

*@ +
+
+
+
+
+
+ @* + *@ + @Html.HiddenFor(x => x.SerialeGiro) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.DataGiro) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.CodAutista) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.Autista) + +
+
+ + + +
+
+ @* + *@ + @Html.HiddenFor(x => x.BancaliRecuperati) + @Html.DisplayFor(x => x.BancaliRecuperati) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.ImportoDaRecuperare) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.ImportoRecuperato) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.DataChiusura) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.CodMezzo) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.Automezzo) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.parzialeBanRec) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.parzialeImpRec) + +
+
+ @* + *@ + @Html.HiddenFor(x => x.NoteChiusura) + +
+
 
+ +
+
+
+ +
+ @* Back to List *@ +
+ diff --git a/Views/Giri/Index.cshtml b/Views/Giri/Index.cshtml index a23709b..1a82dcd 100644 --- a/Views/Giri/Index.cshtml +++ b/Views/Giri/Index.cshtml @@ -96,7 +96,7 @@ nocons - nocons + nocons nocons