From c1eef15b995790003186a6169ffc66119fdb33c2 Mon Sep 17 00:00:00 2001 From: michele Date: Fri, 3 Oct 2025 16:03:05 +0200 Subject: [PATCH 1/5] modificato layout --- Views/Rapp_New/ShowImage.cshtml | 1 + 1 file changed, 1 insertion(+) diff --git a/Views/Rapp_New/ShowImage.cshtml b/Views/Rapp_New/ShowImage.cshtml index 6b0fa82..1af313c 100644 --- a/Views/Rapp_New/ShowImage.cshtml +++ b/Views/Rapp_New/ShowImage.cshtml @@ -1,5 +1,6 @@ @{ ViewData["Title"] = "Visualizza immagine"; + Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; var fileName = ViewBag.FileName as string; } From e84103edbc00e323669013982e2a8074981bc42a Mon Sep 17 00:00:00 2001 From: michele Date: Mon, 6 Oct 2025 16:58:03 +0200 Subject: [PATCH 2/5] Aggiunta dialog quando salvo dati in create e edit dati azienda --- Controllers/DatiAziendaController.cs | 40 ++++++++---- Views/DatiAzienda/Create.cshtml | 65 ++++++++++++++++--- Views/DatiAzienda/Dialog.cshtml | 61 ++++++++++++++++++ Views/DatiAzienda/Edit.cshtml | 94 +++++++++++++++++++++------- 4 files changed, 218 insertions(+), 42 deletions(-) create mode 100644 Views/DatiAzienda/Dialog.cshtml diff --git a/Controllers/DatiAziendaController.cs b/Controllers/DatiAziendaController.cs index 0657f95..4429139 100644 --- a/Controllers/DatiAziendaController.cs +++ b/Controllers/DatiAziendaController.cs @@ -40,6 +40,9 @@ namespace VirtualTask.Controllers _urlLoghi = _configuration["ApplicationInsights:rootUrlApi2"]; } + + #region INDEX + public IActionResult Index() { SessionHelper helper = new SessionHelper(this); @@ -78,6 +81,7 @@ namespace VirtualTask.Controllers return RedirectToAction("Error"); } } + #endregion #region CREATE @@ -96,28 +100,29 @@ namespace VirtualTask.Controllers SessionHelper helper = new SessionHelper(this); string token = helper.GetStringValue("tok"); string tenant2 = helper.GetStringValue("tenant2"); // tenant = azienda - string apiUrl = helper.GetStringValue("apiUrl"); string admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; ViewBag.AllTecnici = getTecnici(); + // ❌ Validazione fallita → restituisco errori in JSON if (!ModelState.IsValid) - return View(model); + { + var errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage).ToList(); + return BadRequest(string.Join("\n", errors)); + } string logoUrl = null; - // 1️⃣ Upload del logo tramite API UploadLogo // 1️⃣ Upload del logo tramite API UploadLogo if (model.logo != null && model.logo.Length > 0) { - // ✅ Token nella query string string uploadUrl = $"{apiUrl}datiazienda/upload_logo?token={token}"; using (var httpClient = new HttpClient()) using (var form = new MultipartFormDataContent()) { - // ⚡ Solo il file nel multipart var fileContent = new StreamContent(model.logo.OpenReadStream()); fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue( string.IsNullOrWhiteSpace(model.logo.ContentType) ? "application/octet-stream" : model.logo.ContentType @@ -129,17 +134,15 @@ namespace VirtualTask.Controllers if (!response.IsSuccessStatusCode) { string err = await response.Content.ReadAsStringAsync(); - ModelState.AddModelError("", "Errore upload logo: " + err); - return View(model); + return BadRequest("Errore upload logo: " + err); } dynamic result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); logoUrl = result.url; } - } - // 2️⃣ Creazione oggetto da inviare all'API datiazienda/add + // 2️⃣ Creo l'oggetto da inviare all'API var dat = new DatiAziendaTable { azienda = tenant2, @@ -161,12 +164,20 @@ namespace VirtualTask.Controllers if (!saveResponse.IsSuccessStatusCode) { string err = await saveResponse.Content.ReadAsStringAsync(); - ModelState.AddModelError("", "Errore salvataggio dati: " + err); - return View(model); + return BadRequest("Errore salvataggio dati: " + err); } } - return RedirectToAction("Index"); + // ✅ Risposta JSON usata dalla view per aprire la finestra popup + return Json(new { success = true }); + } + + /// + /// Pagina popup mostrata dopo il salvataggio + /// + public IActionResult Dialog() + { + return View(); } #endregion CREATE @@ -274,7 +285,10 @@ namespace VirtualTask.Controllers } } - return RedirectToAction("Index"); + //return RedirectToAction("Index"); + // ✅ Risposta OK per far apparire la dialog nella view + return Ok(); + } #endregion diff --git a/Views/DatiAzienda/Create.cshtml b/Views/DatiAzienda/Create.cshtml index 5f693e7..cd5d490 100644 --- a/Views/DatiAzienda/Create.cshtml +++ b/Views/DatiAzienda/Create.cshtml @@ -4,61 +4,110 @@ ViewData["Title"] = "Nuova Intestazione Buoni Intervento"; Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; } +
-
+
@Html.HiddenFor(x => x.azienda) @Html.HiddenFor(x => x.url_logo) +
- @Html.DropDownListFor(x =>x.tecnico,(IEnumerable)ViewBag.AllTecnici,new {@class = "form-control"}) + @Html.DropDownListFor(x => x.tecnico, (IEnumerable)ViewBag.AllTecnici, new { @class = "form-control" })
+
 
+
+
 
+
+
 
+
- @**@
+
 
+
-
- @* Torna alla lista *@ -
+ + @section Scripts { - @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + } } diff --git a/Views/DatiAzienda/Dialog.cshtml b/Views/DatiAzienda/Dialog.cshtml new file mode 100644 index 0000000..af373ca --- /dev/null +++ b/Views/DatiAzienda/Dialog.cshtml @@ -0,0 +1,61 @@ +@{ + Layout = null; +} + + + + + + Dati salvati + + + +

Dati salvati correttamente ✅

+

I dati non saranno visibili nell'app finché non effettuerai il logout e login.

+ + + + + + diff --git a/Views/DatiAzienda/Edit.cshtml b/Views/DatiAzienda/Edit.cshtml index 8ac4639..6621c86 100644 --- a/Views/DatiAzienda/Edit.cshtml +++ b/Views/DatiAzienda/Edit.cshtml @@ -10,61 +10,113 @@
-
+
@Html.HiddenFor(x => x.azienda) @Html.HiddenFor(x => x.url_logo) @Html.HiddenFor(x => x.logo)
-
- @Html.DropDownListFor(x => x.tecnico,(IEnumerable)ViewBag.AllTecnici, new {@class = "form-control"}) +
+ @Html.DropDownListFor(x => x.tecnico, (IEnumerable)ViewBag.AllTecnici, new { @class = "form-control" })
-
 
+
-
+
-
 
+
-
+
@{ - byte[] appo = Model.logo; - var base64 = Convert.ToBase64String(appo); - var imgSrc = String.Format("data:image/gif;base64,{0}", base64); + if (Model.logo != null && Model.logo.Length > 0) + { + var base64 = Convert.ToBase64String(Model.logo); + var imgSrc = $"data:image/png;base64,{base64}"; + + } } -
-
 
+
-
- +
+
-
-
- @* Back to List *@ +
+
+ + + + + + - @section Scripts { - @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + } + } From 9bf20bb7e87253734226dc2cb130833abf4cf142 Mon Sep 17 00:00:00 2001 From: michele Date: Mon, 6 Oct 2025 17:34:32 +0200 Subject: [PATCH 3/5] modifica dialog --- Views/DatiAzienda/Create.cshtml | 39 ++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/Views/DatiAzienda/Create.cshtml b/Views/DatiAzienda/Create.cshtml index cd5d490..09d59eb 100644 --- a/Views/DatiAzienda/Create.cshtml +++ b/Views/DatiAzienda/Create.cshtml @@ -59,6 +59,23 @@ + + + @section Scripts { @@ -69,7 +86,11 @@ + } From 4e34943d8dd0de32662fbc503a61271dbdb0b3dc Mon Sep 17 00:00:00 2001 From: michele Date: Thu, 9 Oct 2025 16:43:01 +0200 Subject: [PATCH 4/5] reso obbliagatorio campo stato nelle chiamate --- Models/Chiamate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Models/Chiamate.cs b/Models/Chiamate.cs index aee9106..16ce99b 100644 --- a/Models/Chiamate.cs +++ b/Models/Chiamate.cs @@ -47,7 +47,7 @@ namespace VirtualTask.Models [Display(Name = "Tecnico")] public string? chtchiam { get; set; } - [Display(Name = "Stato")] + [Display(Name = "Stato"), Required(ErrorMessage = "Selezionare uno stato di assegnazione")] public string? chstato { get; set; } [Display(Name = "Rifiutata")] From c61c1b70395e00b309dbb4fc7762e8f73df644c3 Mon Sep 17 00:00:00 2001 From: michele Date: Mon, 13 Oct 2025 17:36:42 +0200 Subject: [PATCH 5/5] Modifca gestione stato chiamate, tolta tendina di selezione --- Controllers/ChiamateController.cs | 5 +++++ Models/Chiamate.cs | 2 +- Views/Chiamate/Create.cshtml | 4 ++-- Views/Chiamate/Index.cshtml | 16 ++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Controllers/ChiamateController.cs b/Controllers/ChiamateController.cs index 0b52816..3cb824c 100644 --- a/Controllers/ChiamateController.cs +++ b/Controllers/ChiamateController.cs @@ -245,6 +245,11 @@ namespace VirtualTask.Controllers //model.chdtapp = model.chdata; model.chdtass = model.chdata; model.chtipo = "A";//X=creato da app, A creato da adhoc. DEVO METTERE A perche altrimenti l'app lo tratta come una chiamata da commessa + + if (model.chtchiam != null) + { + model.chstato = "C"; + } model.chmodrac = "EMAIL"; //int year=adesso.Year; //int ora = adesso.Hour; diff --git a/Models/Chiamate.cs b/Models/Chiamate.cs index 16ce99b..f5bdbef 100644 --- a/Models/Chiamate.cs +++ b/Models/Chiamate.cs @@ -47,7 +47,7 @@ namespace VirtualTask.Models [Display(Name = "Tecnico")] public string? chtchiam { get; set; } - [Display(Name = "Stato"), Required(ErrorMessage = "Selezionare uno stato di assegnazione")] + [Display(Name = "Stato")/*, Required(ErrorMessage = "Selezionare uno stato di assegnazione")*/] public string? chstato { get; set; } [Display(Name = "Rifiutata")] diff --git a/Views/Chiamate/Create.cshtml b/Views/Chiamate/Create.cshtml index aa0bc74..2c7cffb 100644 --- a/Views/Chiamate/Create.cshtml +++ b/Views/Chiamate/Create.cshtml @@ -25,12 +25,12 @@ @Html.DropDownListFor(x => x.chtchiam, (IEnumerable)ViewBag.Tecnici, new { @class = "agy-form-field require" }) -
 
+ @*
 
@Html.DropDownListFor(x => x.chstato, (IEnumerable)ViewBag.StatiChiamata, new { @class = "agy-form-field require" }) -
+ *@
 
diff --git a/Views/Chiamate/Index.cshtml b/Views/Chiamate/Index.cshtml index 13a1be8..9081b2d 100644 --- a/Views/Chiamate/Index.cshtml +++ b/Views/Chiamate/Index.cshtml @@ -216,14 +216,14 @@ @Html.PagedListPager(Model, page => Url.Action("index", new { page = page, - cliente = ViewData["ClienteFilter"], - impianto = ViewData["CurrentFilter"], - tecnico = ViewData["CurrentFilterTec"], - indirizzo = ViewData["CurrentFilterIndiri"], - stato = ViewData["CurrentFilterStato"], - dataIni = ViewData["CurrentFilterDataDa"], - dataFin = ViewData["CurrentFilterDataA"] - }), new PagedListRenderOptions() + cliente = ViewData["ClienteFilter"], + impianto = ViewData["CurrentFilter"], + tecnico = ViewData["CurrentFilterTec"], + indirizzo = ViewData["CurrentFilterIndiri"], + stato = ViewData["CurrentFilterStato"], + dataIni = ViewData["CurrentFilterDataDa"], + dataFin = ViewData["CurrentFilterDataA"] + }), new PagedListRenderOptions() { ActiveLiElementClass = "active", PageClasses = new[] { "page-link" },