From 4845c549b6cdae385494d6e4b864a83419829c53 Mon Sep 17 00:00:00 2001 From: Marco Audiffredi Date: Thu, 21 Dec 2023 10:18:10 +0100 Subject: [PATCH] Dati azienda dettaglio e eliminazione --- Controllers/DatiAziendaController.cs | 113 ++++++++++++++++++++++++++- Views/DatiAzienda/Create.cshtml | 76 +++++++++--------- Views/DatiAzienda/Delete.cshtml | 74 ++++++++++++++++++ Views/DatiAzienda/Detail.cshtml | 51 ++++++++++++ Views/DatiAzienda/Index.cshtml | 7 +- appsettings.json | 12 +-- 6 files changed, 282 insertions(+), 51 deletions(-) create mode 100644 Views/DatiAzienda/Delete.cshtml create mode 100644 Views/DatiAzienda/Detail.cshtml diff --git a/Controllers/DatiAziendaController.cs b/Controllers/DatiAziendaController.cs index f4872aa..e92010d 100644 --- a/Controllers/DatiAziendaController.cs +++ b/Controllers/DatiAziendaController.cs @@ -212,7 +212,7 @@ namespace VirtualTask.Controllers string pic = System.IO.Path.GetFileName(model.logo2.FileName); string path = string.Format("{0}{1}\\{2}", _pathLoghi, tenant2, pic); //string projectRootPath = _hostingEnvironment.ContentRootPath; - + //// file is uploaded using (Stream fileStream = new FileStream(path, FileMode.Create)) { @@ -229,6 +229,7 @@ namespace VirtualTask.Controllers model.logo = array; } model.logo2 = null; + model.url_logo = string.Format("{0}{1}/{2}", _urlLoghi, tenant2, pic); ; } @@ -256,8 +257,116 @@ namespace VirtualTask.Controllers } #endregion + #region DETAIL + public IActionResult Detail(string azienda, string tecnico) + { + SessionHelper helper = new SessionHelper(this); - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + token = helper.GetStringValue("tok"); + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + urlBase = apiUrl + "datiaziendaList"; + urlBase = urlBase + "?token=" + token; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + DatiAziendaTable dat = new DatiAziendaTable(); + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + dat = modelList.Where(t => t.azienda.Equals(azienda) && t.tecnico.Equals(tecnico)).First(); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + + + + ViewBag.AllTecnici = getTecnici(); + return View(dat); + } + #endregion + + #region DELETE + [HttpGet] + public IActionResult Delete(string azienda, string tecnico) + { + SessionHelper helper = new SessionHelper(this); + + token = helper.GetStringValue("tok"); + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + urlBase = apiUrl + "datiaziendaList"; + urlBase = urlBase + "?token=" + token; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + DatiAziendaTable dat = new DatiAziendaTable(); + + List modelList = new List(); + + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + dat = modelList.Where(x => x.azienda.Equals(azienda) && x.tecnico.Equals(tecnico)).First(); + } + + return View(dat); + } + + [HttpPost, ActionName("DeleteConfirmed")] + public IActionResult DeleteConfirmed(string azienda, string tecnico) + { + SessionHelper helper = new SessionHelper(this); + + token = helper.GetStringValue("tok"); + tenant = helper.GetStringValue("tenant"); + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + urlBase = apiUrl + "datiazienda/del"; + urlBase = urlBase + "?azienda=" + azienda; + urlBase = urlBase + "&tecnico=" + tecnico; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + string data = JsonConvert.SerializeObject(azienda); + 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"); + } + } + #endregion DELETE + + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { SessionHelper helper = new SessionHelper(this); diff --git a/Views/DatiAzienda/Create.cshtml b/Views/DatiAzienda/Create.cshtml index f4023a4..04345e7 100644 --- a/Views/DatiAzienda/Create.cshtml +++ b/Views/DatiAzienda/Create.cshtml @@ -4,49 +4,49 @@ ViewData["Title"] = "Nuovo"; Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; } +
+
+
+
+
+
+
-

Create

- -

DatiAzienda

-
-
-
- -
- - @Html.HiddenFor(x => x.azienda) - @Html.HiddenFor(x => x.url_logo) -
- - @Html.DropDownListFor(x =>x.tecnico,(IEnumerable)ViewBag.AllTecnici,new {@class = "form-control"}) - + @Html.HiddenFor(x => x.azienda) + @Html.HiddenFor(x => x.url_logo) +
+ + @Html.DropDownListFor(x =>x.tecnico,(IEnumerable)ViewBag.AllTecnici,new {@class = "form-control"}) + +
+
+ + + +
+
+ + + +
+
+ + @**@ + + +
+
+ +
+ +
-
- - - + -
- - - -
-
- - @**@ - - -
-
- -
- +
- - @section Scripts { @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} diff --git a/Views/DatiAzienda/Delete.cshtml b/Views/DatiAzienda/Delete.cshtml new file mode 100644 index 0000000..f280691 --- /dev/null +++ b/Views/DatiAzienda/Delete.cshtml @@ -0,0 +1,74 @@ +@model VirtualTask.Models.DatiAziendaTable + +@{ + ViewData["Title"] = "Elimina"; + Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; +} + +
+
+
+
+
+ @Html.DisplayNameFor(model => model.azienda) +
+
+ @Html.DisplayFor(model => model.azienda) +
+
+ @Html.DisplayNameFor(model => model.logo) +
+
+ @{ + var base64 = Convert.ToBase64String(Model.logo); + var imgSrc = String.Format("data:image/gif;base64,{0}", base64); + } + +
+
+ @Html.DisplayNameFor(model => model.tecnico) +
+
+ @Html.DisplayFor(model => model.tecnico) +
+
+ @Html.DisplayNameFor(model => model.ragsoc) +
+
+ @Html.DisplayFor(model => model.ragsoc) +
+
+ @Html.DisplayNameFor(model => model.url_logo) +
+
+ @Html.DisplayFor(model => model.url_logo) +
+
+ @Html.DisplayNameFor(model => model.testo_buono) +
+
+ @{ + string testo = string.Empty; + testo = Model.testo_buono; + } + @Html.Raw(@testo) +
+ +
+
 
+
+ + model.azienda) name="azienda" /> + model.tecnico) name="tecnico" /> + +
+
+
+
+ + + + + diff --git a/Views/DatiAzienda/Detail.cshtml b/Views/DatiAzienda/Detail.cshtml new file mode 100644 index 0000000..baa3972 --- /dev/null +++ b/Views/DatiAzienda/Detail.cshtml @@ -0,0 +1,51 @@ +@model VirtualTask.Models.DatiAziendaTable + +@{ + ViewData["Title"] = "Dettaglio"; + Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; +} + +
+
+
+
+
+ @Html.DisplayNameFor(model => model.azienda)   @Html.DisplayFor(model => model.azienda) +
+
+ @{ + var base64 = Convert.ToBase64String(Model.logo); + var imgSrc = String.Format("data:image/gif;base64,{0}", base64); + } + +
+
+ @Html.DisplayNameFor(model => model.tecnico)   @Html.DisplayFor(model => model.tecnico) +
+
+ @Html.DisplayNameFor(model => model.ragsoc)   @Html.DisplayFor(model => model.ragsoc) +
+
+ @Html.DisplayNameFor(model => model.url_logo)   @Html.DisplayFor(model => model.url_logo) +
+
+ @Html.DisplayNameFor(model => model.testo_buono)    + @{ + string testo = string.Empty; + testo = Model.testo_buono; + } + @Html.Raw(@testo) +
+ + +
+
+
+
+ + + diff --git a/Views/DatiAzienda/Index.cshtml b/Views/DatiAzienda/Index.cshtml index 93f6ff4..d2a66f0 100644 --- a/Views/DatiAzienda/Index.cshtml +++ b/Views/DatiAzienda/Index.cshtml @@ -61,19 +61,16 @@ -@* @Html.ActionLink("Edit", "Edit", new { azienda=item.azienda,tecnico=item.tecnico }) | - @Html.ActionLink("Details", "Details", new { azienda=item.azienda,tecnico=item.tecnico }) | - @Html.ActionLink("Delete", "Delete", new { azienda=item.azienda,tecnico=item.tecnico })*@ Modifica | - Dettaglio | - Elimina diff --git a/appsettings.json b/appsettings.json index b668d60..e3d09a7 100644 --- a/appsettings.json +++ b/appsettings.json @@ -7,14 +7,14 @@ }, "ApplicationInsights": { //PRODUZIONE - "rootUrlApi": "https://api.poloinformatico.it:9000/api/Polo/", - "rootWebLoghi": "C:\\ZAPIPOLO\\api_polo\\wwwroot\\VIRTU\\", - "rootUrlApi2": "https://api.poloinformatico.it:9000/VIRTU/", + //"rootUrlApi": "https://api.poloinformatico.it:9000/api/Polo/", + //"rootWebLoghi": "C:\\ZAPIPOLO\\api_polo\\wwwroot\\VIRTU\\", + //"rootUrlApi2": "https://api.poloinformatico.it:9000/VIRTU/", //TEST - //"rootUrlApi": "http://testapi.poloinformatico.it:9001/api/Polo/", - //"rootWebLoghi": "C:\\SORGENTI\\_publish\\wwwroot\\VIRTU\\", - //"rootUrlApi2": "http://testapi.poloinformatico.it:9001/VIRTU/", + "rootUrlApi": "http://testapi.poloinformatico.it:9001/api/Polo/", + "rootWebLoghi": "C:\\SORGENTI\\_publish\\wwwroot\\VIRTU\\", + "rootUrlApi2": "http://testapi.poloinformatico.it:9001/VIRTU/", "mittenteMail": "info@virtualtask.it", "nomeMail": "Supporto Virtual Task",