From fdab186e2074c7d775526eef96448c06be1e1ac1 Mon Sep 17 00:00:00 2001 From: michele Date: Thu, 17 Oct 2024 11:02:13 +0200 Subject: [PATCH] Aggiunto View e metodo nel controller per Disabilita utente --- Controllers/RegistrazioniController.cs | 95 ++++++- Views/Registrazioni/Disattiva.cshtml | 244 ++++++++++++++++++ Views/Registrazioni/Index.cshtml | 6 +- .../icons8-rimuovere-l'utente-uomo-50.png | Bin 0 -> 1052 bytes 4 files changed, 335 insertions(+), 10 deletions(-) create mode 100644 Views/Registrazioni/Disattiva.cshtml create mode 100644 wwwroot/assets/images/icons8-rimuovere-l'utente-uomo-50.png diff --git a/Controllers/RegistrazioniController.cs b/Controllers/RegistrazioniController.cs index f0d054e..bd0c6af 100644 --- a/Controllers/RegistrazioniController.cs +++ b/Controllers/RegistrazioniController.cs @@ -491,9 +491,8 @@ namespace VirtualTask.Controllers if (response.IsSuccessStatusCode) { - string data = response.Content.ReadAsStringAsync().Result; - string e = JsonConvert.DeserializeObject(data); - + //string data = response.Content.ReadAsStringAsync().Result; + //string e = JsonConvert.DeserializeObject(data); return RedirectToAction("Index"); } @@ -510,12 +509,92 @@ namespace VirtualTask.Controllers helper.SetStringValue("errMsg", "Utente non abilitato per la funzione"); return RedirectToAction("Error"); } - - - - - } + + #endregion + + #region DISATTIVA + + [HttpGet] + public IActionResult Disattiva(int id) + { + SessionHelper helper = new SessionHelper(this); + + //token = helper.GetStringValue("tok"); + + apiUrl = helper.GetStringValue("apiUrl"); + urlBase = apiUrl + "RegistrazioniList"; + //urlBase = "http://10.0.0.187:8000/api/Polo/RegistrazioniList"; + //urlBase = urlBase + "?token=" + token; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + + Registrazione reg = new Registrazione(); + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + reg = modelList.Where(x => x.id.Equals(id)).First(); + return View(reg); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + } + + + [HttpPost] + public IActionResult Disattiva(Registrazione model) + { + SessionHelper helper = new SessionHelper(this); + apiUrl = helper.GetStringValue("apiUrl"); + token = helper.GetStringValue("tok"); + string errore = string.Empty; + admin = helper.GetStringValue("admin"); + // prima verifico che l'utente connesso sia SA + if (!string.IsNullOrEmpty(admin) && admin.Equals("S")) + { + urlBase = apiUrl + "DisattivazioneStored"; + urlBase = urlBase + "?token=" + token; + urlBase = urlBase + "&id=" + model.id; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + //string data = response.Content.ReadAsStringAsync().Result; + //string e = JsonConvert.DeserializeObject(data); + + return RedirectToAction("Index"); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", "Errore in attivazione"); + return RedirectToAction("Error"); + } + + } + else + { + helper.SetStringValue("errMsg", "Utente non abilitato per la funzione"); + return RedirectToAction("Error"); + } + } + #endregion [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/Views/Registrazioni/Disattiva.cshtml b/Views/Registrazioni/Disattiva.cshtml new file mode 100644 index 0000000..ba972f5 --- /dev/null +++ b/Views/Registrazioni/Disattiva.cshtml @@ -0,0 +1,244 @@ +@model VirtualTask.Models.Registrazione + + +@{ + ViewData["Title"] = "Disattiva"; + Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; +} + + +
+
+
+
+
+
+ +
+ @Html.DisplayNameFor(model => model.id) @Html.DisplayFor(model => model.id) +
+
+ @Html.DisplayNameFor(model => model.nome) @Html.DisplayFor(model => model.nome) +
+
+ @Html.DisplayNameFor(model => model.cognome) @Html.DisplayFor(model => model.cognome) +
+
+ @Html.DisplayNameFor(model => model.RagioneSociale) @Html.DisplayFor(model => model.RagioneSociale) +
+
+ @Html.DisplayNameFor(model => model.telefono) @Html.DisplayFor(model => model.telefono) +
+
+ @Html.DisplayNameFor(model => model.cellulare) @Html.DisplayFor(model => model.cellulare) +
+
+ @Html.DisplayNameFor(model => model.email) @Html.DisplayFor(model => model.email) +
+
+ @Html.DisplayNameFor(model => model.emailConf) @Html.DisplayFor(model => model.emailConf) +
+
+ @Html.DisplayNameFor(model => model.azienda) @Html.DisplayFor(model => model.azienda) +
+
+ @Html.DisplayNameFor(model => model.username) @Html.DisplayFor(model => model.username) +
+
+ @Html.DisplayNameFor(model => model.passwd) @Html.DisplayFor(model => model.passwd) +
+
+ @Html.DisplayNameFor(model => model.citta) @Html.DisplayFor(model => model.citta) +
+
+ @Html.DisplayNameFor(model => model.provincia) @Html.DisplayFor(model => model.provincia) +
+
+ @Html.DisplayNameFor(model => model.nazione) @Html.DisplayFor(model => model.nazione) +
+
+ @Html.DisplayNameFor(model => model.attivato) @Html.DisplayFor(model => model.attivato) +
+ @Html.HiddenFor(model => model.id) + @Html.HiddenFor(model => model.nome) + @Html.HiddenFor(model => model.cognome) + @Html.HiddenFor(model => model.telefono) + @Html.HiddenFor(model => model.cellulare) + @Html.HiddenFor(model => model.email) + @Html.HiddenFor(model => model.emailConf) + @Html.HiddenFor(model => model.azienda) + @Html.HiddenFor(model => model.username) + @Html.HiddenFor(model => model.passwd) + @Html.HiddenFor(model => model.citta) + @Html.HiddenFor(model => model.provincia) + @Html.HiddenFor(model => model.nazione) + @Html.HiddenFor(model => model.attivato) + @Html.HiddenFor(model => model.token) + @Html.HiddenFor(model => model.privacy1) + @Html.HiddenFor(model => model.privacy2) + @Html.HiddenFor(model => model.privacy3) + @Html.HiddenFor(model => model.privacy4) + @Html.HiddenFor(model => model.ModuloTimesheet) + @Html.HiddenFor(model => model.ModuloRapportini) + @Html.HiddenFor(model => model.RagioneSociale) + + +
+
+ Torna alla lista + @* *@ +
+
+
+
+
+
+ +@*
+

Registrazione

+
+
+
+ @Html.DisplayNameFor(model => model.id) +
+
+ @Html.DisplayFor(model => model.id) +
+
+ @Html.DisplayNameFor(model => model.nome) +
+
+ @Html.DisplayFor(model => model.nome) +
+
+ @Html.DisplayNameFor(model => model.cognome) +
+
+ @Html.DisplayFor(model => model.cognome) +
+
+ @Html.DisplayNameFor(model => model.telefono) +
+
+ @Html.DisplayFor(model => model.telefono) +
+
+ @Html.DisplayNameFor(model => model.cellulare) +
+
+ @Html.DisplayFor(model => model.cellulare) +
+
+ @Html.DisplayNameFor(model => model.email) +
+
+ @Html.DisplayFor(model => model.email) +
+
+ @Html.DisplayNameFor(model => model.emailConf) +
+
+ @Html.DisplayFor(model => model.emailConf) +
+
+ @Html.DisplayNameFor(model => model.azienda) +
+
+ @Html.DisplayFor(model => model.azienda) +
+
+ @Html.DisplayNameFor(model => model.username) +
+
+ @Html.DisplayFor(model => model.username) +
+
+ @Html.DisplayNameFor(model => model.passwd) +
+
+ @Html.DisplayFor(model => model.passwd) +
+
+ @Html.DisplayNameFor(model => model.citta) +
+
+ @Html.DisplayFor(model => model.citta) +
+
+ @Html.DisplayNameFor(model => model.provincia) +
+
+ @Html.DisplayFor(model => model.provincia) +
+
+ @Html.DisplayNameFor(model => model.nazione) +
+
+ @Html.DisplayFor(model => model.nazione) +
+
+ @Html.DisplayNameFor(model => model.attivato) +
+
+ @Html.DisplayFor(model => model.attivato) +
+
+ @Html.DisplayNameFor(model => model.token) +
+
+ @Html.DisplayFor(model => model.token) +
+
+ @Html.DisplayNameFor(model => model.privacy1) +
+
+ @Html.DisplayFor(model => model.privacy1) +
+
+ @Html.DisplayNameFor(model => model.privacy2) +
+
+ @Html.DisplayFor(model => model.privacy2) +
+
+ @Html.DisplayNameFor(model => model.privacy3) +
+
+ @Html.DisplayFor(model => model.privacy3) +
+
+ @Html.DisplayNameFor(model => model.privacy4) +
+
+ @Html.DisplayFor(model => model.privacy4) +
+
+ @Html.DisplayNameFor(model => model.ModuloTimesheet) +
+
+ @Html.DisplayFor(model => model.ModuloTimesheet) +
+
+ @Html.DisplayNameFor(model => model.ModuloRapportini) +
+
+ @Html.DisplayFor(model => model.ModuloRapportini) +
+
+ @Html.DisplayNameFor(model => model.RagioneSociale) +
+
+ @Html.DisplayFor(model => model.RagioneSociale) +
+
+ @Html.DisplayNameFor(model => model.numtec) +
+
+ @Html.DisplayFor(model => model.numtec) +
+
+
+
+ @Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) | + Back to List +
*@ diff --git a/Views/Registrazioni/Index.cshtml b/Views/Registrazioni/Index.cshtml index a1f84b5..52d422f 100644 --- a/Views/Registrazioni/Index.cshtml +++ b/Views/Registrazioni/Index.cshtml @@ -92,10 +92,12 @@ Elimina - + Attiva - + + Disattiva + } diff --git a/wwwroot/assets/images/icons8-rimuovere-l'utente-uomo-50.png b/wwwroot/assets/images/icons8-rimuovere-l'utente-uomo-50.png new file mode 100644 index 0000000000000000000000000000000000000000..4df45ffa78d2b916cf1afc4ec3c659589ce563a6 GIT binary patch literal 1052 zcmV+%1mpXOP)U$T>Xd-nd%+THuCz1BJxk~0@*13m?I0^5Ksz+1qRNkcA!hmR_45}-vzz^7Ly~Mbqu@!yazlnM&BA>YsCun029dp`()4% zP#dAYO=bb`F>p;|2k^{Gzyn|eXpS*{HgH3ec?XZImJx*n8lN~@%p3b<#D@tq=1b!u z9yux_UQg(@?*XGeANoHuk;a5NH>G19&EJJNXuPaKv3Nlxmi(zuOBdSpav z0*yt|IEhEL$cXL)8XKkYB_4TOMjT9_@x3%w;E{J_#6K~^^QVAeX;_TrjYBeGQ%Il~ zhK<=QjRSb(oQ#MQX9YA%;|w0@lM$9s#pNSuSpMRTRWjm|lBa6v(pb}2iATl({fd)r zD%XfgjT4#_q~)FCGN`GFF|TTjJ!iRLr;Pf%iZR_9vx^+@nvAk+@A-)F)n6L3gq-oM z470Q4xsZO7fnU`3H*&~}z|{zeR-^jZi9Uy%G9)A42FVr&;Y^OMra3@n%*b~Ku{}QOB z$_huFW!+b0ImePJ---5Juhjp5uJs3o*WtDMk&?_--JX2eu81b2S6mz6CqLuz% z7T2zK9>E0cWzITa3d!iqpzhl%O{+^k#N6F?&IFF8Ts0q*uDR2+Xp`m-!5_v0NA$<* zz%tS&ctP}Xikc0T>A?=?1WxltE`hhQK+>gLWpkPA9Fok_15;8ZkjHf*pXtl5WJ~5- z>zKZDkS&=%?0?5t-fEitkN}0^S-Ia1GM& WZHQZ)RIRN50000