riparazione
This commit is contained in:
parent
3b66fedd2d
commit
991ea9ba5e
@ -245,6 +245,12 @@ namespace VirtualTask.Controllers
|
|||||||
//model.chdtapp = model.chdata;
|
//model.chdtapp = model.chdata;
|
||||||
model.chdtass = 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
|
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";
|
model.chmodrac = "EMAIL";
|
||||||
//int year=adesso.Year;
|
//int year=adesso.Year;
|
||||||
//int ora = adesso.Hour;
|
//int ora = adesso.Hour;
|
||||||
|
|||||||
@ -91,101 +91,92 @@ namespace VirtualTask.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Create(DatiAzienda model)
|
public async Task<IActionResult> Create(DatiAzienda model)
|
||||||
{
|
{
|
||||||
DatiAziendaTable dat=new DatiAziendaTable();
|
|
||||||
|
|
||||||
SessionHelper helper = new SessionHelper(this);
|
SessionHelper helper = new SessionHelper(this);
|
||||||
admin = helper.GetStringValue("admin");
|
string token = helper.GetStringValue("tok");
|
||||||
token = helper.GetStringValue("tok");
|
string tenant2 = helper.GetStringValue("tenant2"); // tenant = azienda
|
||||||
tenant = helper.GetStringValue("tenant");
|
string apiUrl = helper.GetStringValue("apiUrl");
|
||||||
tenant2 = helper.GetStringValue("tenant2");
|
string admin = helper.GetStringValue("admin");
|
||||||
|
|
||||||
ViewBag.Admin = admin;
|
ViewBag.Admin = admin;
|
||||||
if (model.logo != null)
|
ViewBag.AllTecnici = getTecnici();
|
||||||
{
|
|
||||||
string pic = System.IO.Path.GetFileName(model.logo.FileName);
|
|
||||||
//2025-05-05: gestione directory iommagine nel caso che l'azienda sia più corta di 5 caratteri
|
|
||||||
string dir = tenant2;
|
|
||||||
if (!string.IsNullOrEmpty(tenant2) && tenant2.Trim().Length < 5)
|
|
||||||
{
|
|
||||||
dir = tenant2.Trim();
|
|
||||||
}
|
|
||||||
string path = string.Format("{0}{1}\\{2}",_pathLoghi, dir, pic);
|
|
||||||
//string projectRootPath = _hostingEnvironment.ContentRootPath;
|
|
||||||
|
|
||||||
//// file is uploaded
|
// ❌ Validazione fallita → restituisco errori in JSON
|
||||||
using (Stream fileStream = new FileStream(path, FileMode.Create))
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
model.logo.CopyToAsync(fileStream);
|
var errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage).ToList();
|
||||||
|
return BadRequest(string.Join("\n", errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
//// save the image path path to the database or you can send image
|
string logoUrl = null;
|
||||||
//// directly to database
|
|
||||||
//// in-case if you want to store byte[] ie. for DB
|
// 1️⃣ Upload del logo tramite API UploadLogo
|
||||||
using (MemoryStream ms = new MemoryStream())
|
if (model.logo != null && model.logo.Length > 0)
|
||||||
{
|
{
|
||||||
model.logo.CopyTo(ms);
|
string uploadUrl = $"{apiUrl}datiazienda/upload_logo?token={token}";
|
||||||
byte[] array = ms.GetBuffer();
|
|
||||||
dat.logo = array;
|
using (var httpClient = new HttpClient())
|
||||||
}
|
using (var form = new MultipartFormDataContent())
|
||||||
dat.azienda = tenant2;
|
{
|
||||||
dat.testo_buono = model.testo_buono;
|
var fileContent = new StreamContent(model.logo.OpenReadStream());
|
||||||
dat.url_logo = string.Format("{0}{1}/{2}", _urlLoghi, dir, pic);
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(
|
||||||
dat.ragsoc = model.ragsoc;
|
string.IsNullOrWhiteSpace(model.logo.ContentType) ? "application/octet-stream" : model.logo.ContentType
|
||||||
dat.tecnico = model.tecnico;
|
);
|
||||||
|
form.Add(fileContent, "file", model.logo.FileName);
|
||||||
|
|
||||||
|
HttpResponseMessage response = await httpClient.PostAsync(uploadUrl, form);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string err = await response.Content.ReadAsStringAsync();
|
||||||
|
return BadRequest("Errore upload logo: " + err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dynamic result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
|
||||||
|
logoUrl = result.url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2️⃣ Creo l'oggetto da inviare all'API
|
||||||
|
var dat = new DatiAziendaTable
|
||||||
|
{
|
||||||
|
azienda = tenant2,
|
||||||
|
tecnico = model.tecnico,
|
||||||
|
ragsoc = model.ragsoc,
|
||||||
|
testo_buono = model.testo_buono,
|
||||||
|
url_logo = logoUrl,
|
||||||
|
logo = model.logo != null ? await ConvertToByteArrayAsync(model.logo) : null
|
||||||
|
};
|
||||||
|
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
// 3️⃣ Invio dati all'API datiazienda/add
|
||||||
admin = helper.GetStringValue("admin");
|
string apiAddUrl = apiUrl + "datiazienda/add?token=" + token;
|
||||||
ViewBag.Admin = admin;
|
using (var httpClient = new HttpClient())
|
||||||
urlBase = apiUrl + "datiazienda/add";
|
{
|
||||||
urlBase = urlBase + "?token=" + token;
|
|
||||||
Uri baseAddress = new Uri(urlBase);
|
|
||||||
client = new HttpClient();
|
|
||||||
client.BaseAddress = baseAddress;
|
|
||||||
|
|
||||||
string data = JsonConvert.SerializeObject(dat);
|
string data = JsonConvert.SerializeObject(dat);
|
||||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
HttpResponseMessage saveResponse = await httpClient.PostAsync(apiAddUrl, content);
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (!saveResponse.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
//prima di andare alla pagina devo chiamare il metodo per
|
string err = await saveResponse.Content.ReadAsStringAsync();
|
||||||
//salvare il file in locale in modo che sia visibile sul web dall'app
|
return BadRequest("Errore salvataggio dati: " + err);
|
||||||
//C:\ZAPIPOLO\loghi
|
}
|
||||||
//https://api.poloinformatico.it:9000/api/Polo/datiazienda/saveFile?azienda=AZI02&tecnico=aaaaa%20%20%20%20%20%20%20%20%20%20&pathSrv=C%3A%5CZAPIPOLO%5Cloghi'
|
}
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
|
||||||
urlBase = apiUrl + "datiazienda/savefile";
|
|
||||||
urlBase = urlBase + "?azienda=" + model.azienda;
|
|
||||||
urlBase = urlBase + "&tecnico=" + model.tecnico;
|
|
||||||
//urlBase = urlBase + "&pathSrv=" + "C:\\ZAPIPOLO\\loghi";
|
|
||||||
urlBase = urlBase + "&pathSrv=" + _pathLoghi;
|
|
||||||
|
|
||||||
baseAddress = new Uri(urlBase);
|
// ✅ Risposta JSON usata dalla view per aprire la finestra popup
|
||||||
client = new HttpClient();
|
return Json(new { success = true });
|
||||||
client.BaseAddress = baseAddress;
|
}
|
||||||
HttpResponseMessage response2 = client.GetAsync(baseAddress).Result;
|
|
||||||
if (response2.IsSuccessStatusCode)
|
/// <summary>
|
||||||
|
/// Pagina popup mostrata dopo il salvataggio
|
||||||
|
/// </summary>
|
||||||
|
public IActionResult Dialog()
|
||||||
{
|
{
|
||||||
return RedirectToAction("Index");
|
return View();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errMes = response.Content.ReadAsStringAsync().Result;
|
|
||||||
helper.SetStringValue("errMsg", errMes);
|
|
||||||
return RedirectToAction("Error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errMes = response.Content.ReadAsStringAsync().Result;
|
|
||||||
helper.SetStringValue("errMsg", errMes);
|
|
||||||
return RedirectToAction("Error");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion CREATE
|
#endregion CREATE
|
||||||
|
|
||||||
#region EDIT
|
#region EDIT
|
||||||
@ -228,102 +219,73 @@ namespace VirtualTask.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Edit(DatiAziendaTable model)
|
public async Task<IActionResult> Edit(DatiAziendaTable model)
|
||||||
{
|
{
|
||||||
SessionHelper helper = new SessionHelper(this);
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
|
||||||
token = helper.GetStringValue("tok");
|
string token = helper.GetStringValue("tok");
|
||||||
tenant = helper.GetStringValue("tenant");
|
string tenant2 = helper.GetStringValue("tenant2");
|
||||||
tenant2 = helper.GetStringValue("tenant2");
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(token))
|
if (string.IsNullOrEmpty(token))
|
||||||
{
|
|
||||||
return RedirectToAction("Login2", "Login");
|
return RedirectToAction("Login2", "Login");
|
||||||
}
|
|
||||||
//model.azienda = tenant;
|
|
||||||
if(model.logo2!=null)
|
|
||||||
{
|
|
||||||
string pic = System.IO.Path.GetFileName(model.logo2.FileName);
|
|
||||||
|
|
||||||
//2025-05-05: gestione directory iommagine nel caso che l'azienda sia più corta di 5 caratteri
|
string apiUrl = helper.GetStringValue("apiUrl");
|
||||||
string dir = tenant2;
|
|
||||||
if (!string.IsNullOrEmpty(tenant2) && tenant2.Trim().Length < 5)
|
|
||||||
{
|
|
||||||
dir = tenant2.Trim();
|
|
||||||
}
|
|
||||||
string path = string.Format("{0}{1}\\{2}", _pathLoghi, dir, pic);
|
|
||||||
//string projectRootPath = _hostingEnvironment.ContentRootPath;
|
|
||||||
|
|
||||||
//// file is uploaded
|
// 1️⃣ Upload del logo tramite API UploadLogo
|
||||||
using (Stream fileStream = new FileStream(path, FileMode.Create))
|
if (model.logo2 != null && model.logo2.Length > 0)
|
||||||
{
|
{
|
||||||
model.logo2.CopyToAsync(fileStream);
|
string uploadUrl = $"{apiUrl}datiazienda/upload_logo?token={token}";
|
||||||
|
|
||||||
|
using (var httpClient = new HttpClient())
|
||||||
|
using (var form = new MultipartFormDataContent())
|
||||||
|
{
|
||||||
|
var fileContent = new StreamContent(model.logo2.OpenReadStream());
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(
|
||||||
|
string.IsNullOrWhiteSpace(model.logo2.ContentType) ? "application/octet-stream" : model.logo2.ContentType
|
||||||
|
);
|
||||||
|
form.Add(fileContent, "file", model.logo2.FileName);
|
||||||
|
|
||||||
|
HttpResponseMessage response = await httpClient.PostAsync(uploadUrl, form);
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string err = await response.Content.ReadAsStringAsync();
|
||||||
|
ModelState.AddModelError("", "Errore upload logo: " + err);
|
||||||
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
//// save the image path path to the database or you can send image
|
dynamic result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
|
||||||
//// directly to database
|
model.url_logo = result.url;
|
||||||
//// in-case if you want to store byte[] ie. for DB
|
}
|
||||||
|
|
||||||
|
// Salvo i byte del file nel modello se serve per il DB
|
||||||
using (MemoryStream ms = new MemoryStream())
|
using (MemoryStream ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
model.logo2.CopyTo(ms);
|
await model.logo2.CopyToAsync(ms);
|
||||||
byte[] array = ms.GetBuffer();
|
model.logo = ms.ToArray();
|
||||||
model.logo = array;
|
|
||||||
}
|
}
|
||||||
model.logo2 = null;
|
model.logo2 = null;
|
||||||
model.url_logo = string.Format("{0}{1}/{2}", _urlLoghi, dir, pic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2️⃣ Invio dati all'API datiazienda/mod
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
string modUrl = $"{apiUrl}datiazienda/mod?token={token}";
|
||||||
urlBase = apiUrl + "datiazienda/mod";
|
using (var client = new HttpClient())
|
||||||
urlBase = urlBase + "?token=" + token;
|
{
|
||||||
Uri baseAddress = new Uri(urlBase);
|
|
||||||
client = new HttpClient();
|
|
||||||
client.BaseAddress = baseAddress;
|
|
||||||
|
|
||||||
string data = JsonConvert.SerializeObject(model);
|
string data = JsonConvert.SerializeObject(model);
|
||||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
HttpResponseMessage response = await client.PostAsync(modUrl, content);
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
//prima di andare alla pagina devo chiamare il metodo per
|
string errMes = await response.Content.ReadAsStringAsync();
|
||||||
//salvare il file in locale in modo che sia visibile sul web dall'app
|
|
||||||
//C:\ZAPIPOLO\loghi
|
|
||||||
//https://api.poloinformatico.it:9000/api/Polo/datiazienda/saveFile?azienda=AZI02&tecnico=aaaaa%20%20%20%20%20%20%20%20%20%20&pathSrv=C%3A%5CZAPIPOLO%5Cloghi'
|
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
|
||||||
urlBase = apiUrl + "datiazienda/savefile";
|
|
||||||
if(!string.IsNullOrEmpty(model.azienda) && model.azienda.Length<5)
|
|
||||||
{
|
|
||||||
model.azienda= model.azienda.Trim();
|
|
||||||
}
|
|
||||||
urlBase = urlBase + "?azienda=" + model.azienda;
|
|
||||||
urlBase = urlBase + "&tecnico=" + model.tecnico.Trim();
|
|
||||||
urlBase = urlBase + "&pathSrv=" + _pathLoghi;
|
|
||||||
baseAddress = new Uri(urlBase);
|
|
||||||
client = new HttpClient();
|
|
||||||
client.BaseAddress = baseAddress;
|
|
||||||
|
|
||||||
data = JsonConvert.SerializeObject(model);
|
|
||||||
content = new StringContent(data, Encoding.UTF8, "application/json");
|
|
||||||
HttpResponseMessage response2 = client.PostAsync(baseAddress, content).Result;
|
|
||||||
if (response2.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errMes = response2.Content.ReadAsStringAsync().Result;
|
|
||||||
helper.SetStringValue("errMsg", errMes);
|
helper.SetStringValue("errMsg", errMes);
|
||||||
return RedirectToAction("Error");
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
//return RedirectToAction("Index");
|
||||||
errMes = response.Content.ReadAsStringAsync().Result;
|
// ✅ Risposta OK per far apparire la dialog nella view
|
||||||
helper.SetStringValue("errMsg", errMes);
|
return Ok();
|
||||||
return RedirectToAction("Error");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -480,5 +442,24 @@ namespace VirtualTask.Controllers
|
|||||||
}
|
}
|
||||||
return selectItems;
|
return selectItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Metodo helper per convertire IFormFile in byte[]
|
||||||
|
private async Task<byte[]> ConvertToByteArrayAsync(IFormFile file)
|
||||||
|
{
|
||||||
|
using (var ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
await file.CopyToAsync(ms);
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Classe per deserializzare la risposta JSON dell'API
|
||||||
|
private class UploadResponse
|
||||||
|
{
|
||||||
|
public string? message { get; set; }
|
||||||
|
public string? url { get; set; }
|
||||||
|
public string? fileName { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,12 +25,12 @@
|
|||||||
@Html.DropDownListFor(x => x.chtchiam, (IEnumerable<SelectListItem>)ViewBag.Tecnici, new { @class = "agy-form-field require" })
|
@Html.DropDownListFor(x => x.chtchiam, (IEnumerable<SelectListItem>)ViewBag.Tecnici, new { @class = "agy-form-field require" })
|
||||||
<span asp-validation-for="chtchiam" class="text-danger"></span>
|
<span asp-validation-for="chtchiam" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
@* <div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
<div class="form-group" style="width: 40%;">
|
<div class="form-group" style="width: 40%;">
|
||||||
<h5><label asp-for="chstato" class="agy-client-quote"></label></h5>
|
<h5><label asp-for="chstato" class="agy-client-quote"></label></h5>
|
||||||
@Html.DropDownListFor(x => x.chstato, (IEnumerable<SelectListItem>)ViewBag.StatiChiamata, new { @class = "agy-form-field require" })
|
@Html.DropDownListFor(x => x.chstato, (IEnumerable<SelectListItem>)ViewBag.StatiChiamata, new { @class = "agy-form-field require" })
|
||||||
<span asp-validation-for="chstato" class="text-danger"></span>
|
<span asp-validation-for="chstato" class="text-danger"></span>
|
||||||
</div>
|
</div> *@
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
<div class="form-group" style="width: 40%;">
|
<div class="form-group" style="width: 40%;">
|
||||||
<h5><label asp-for="chdtapp" class="agy-client-quote"></label></h5>
|
<h5><label asp-for="chdtapp" class="agy-client-quote"></label></h5>
|
||||||
|
|||||||
@ -4,61 +4,133 @@
|
|||||||
ViewData["Title"] = "Nuova Intestazione Buoni Intervento";
|
ViewData["Title"] = "Nuova Intestazione Buoni Intervento";
|
||||||
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
|
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="agy-project-wrapper agy-project-page-wrapper">
|
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form asp-action="Create" enctype="multipart/form-data">
|
<form id="createForm" asp-action="Create" enctype="multipart/form-data">
|
||||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
|
|
||||||
@Html.HiddenFor(x => x.azienda)
|
@Html.HiddenFor(x => x.azienda)
|
||||||
@Html.HiddenFor(x => x.url_logo)
|
@Html.HiddenFor(x => x.url_logo)
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="tecnico" class="control-label"></label></h5>
|
<h5><label asp-for="tecnico" class="control-label"></label></h5>
|
||||||
@Html.DropDownListFor(x => x.tecnico, (IEnumerable<SelectListItem>)ViewBag.AllTecnici, new { @class = "form-control" })
|
@Html.DropDownListFor(x => x.tecnico, (IEnumerable<SelectListItem>)ViewBag.AllTecnici, new { @class = "form-control" })
|
||||||
<span asp-validation-for="tecnico" class="text-danger"></span>
|
<span asp-validation-for="tecnico" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="ragsoc" class="control-label"></label></h5>
|
<h5><label asp-for="ragsoc" class="control-label"></label></h5>
|
||||||
<input asp-for="ragsoc" class="form-control" />
|
<input asp-for="ragsoc" class="form-control" />
|
||||||
<span asp-validation-for="ragsoc" class="text-danger"></span>
|
<span asp-validation-for="ragsoc" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="logo" class="control-label"></label></h5>
|
<h5><label asp-for="logo" class="control-label"></label></h5>
|
||||||
<input type="file" asp-for="logo" />
|
<input type="file" asp-for="logo" />
|
||||||
<span asp-validation-for="logo" class="text-danger"></span>
|
<span asp-validation-for="logo" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="testo_buono" class="control-label"></label></h5>
|
<h5><label asp-for="testo_buono" class="control-label"></label></h5>
|
||||||
@*<input asp-for="testo_buono" class="form-control" />*@
|
|
||||||
<textarea asp-for="testo_buono" class="form-control"></textarea>
|
<textarea asp-for="testo_buono" class="form-control"></textarea>
|
||||||
<span asp-validation-for="testo_buono" class="text-danger"></span>
|
<span asp-validation-for="testo_buono" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="submit" value="Salva" class="agy-btn submitForm" />
|
<input type="submit" value="Salva" class="agy-btn submitForm" />
|
||||||
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
|
<a asp-action="Index" class="agy-btn submitForm">Torna alla lista</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
</div>
|
||||||
@* <a asp-action="Index">Torna alla lista</a> *@
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ✅ Modale di conferma identica a quella della Edit -->
|
||||||
|
<div class="modal fade" id="saveModal" tabindex="-1" role="dialog" aria-labelledby="saveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="saveModalLabel">Dati salvati</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
I dati salvati non saranno visibili nell'app finché non effettuerai il logout.
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" id="modalOkBtn">OK</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="~/js/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
|
<script src="~/js/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
@{
|
||||||
|
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||||
|
}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// inizializza TinyMCE
|
||||||
tinymce.init({
|
tinymce.init({
|
||||||
selector: 'textarea#testo_buono'
|
selector: 'textarea#testo_buono',
|
||||||
|
height: 300,
|
||||||
|
menubar: false,
|
||||||
|
plugins: 'lists link table code',
|
||||||
|
toolbar: 'undo redo | bold italic | bullist numlist | link table | code'
|
||||||
|
});
|
||||||
|
|
||||||
|
// intercetta il submit per gestire la chiamata AJAX + popup
|
||||||
|
document.getElementById('createForm').addEventListener('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
tinymce.triggerSave();
|
||||||
|
|
||||||
|
const form = e.target;
|
||||||
|
const formData = new FormData(form);
|
||||||
|
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
// ✅ Mostra la modale di conferma
|
||||||
|
$('#saveModal').modal('show');
|
||||||
|
|
||||||
|
// reset del form
|
||||||
|
form.reset();
|
||||||
|
if (tinymce.get('testo_buono')) {
|
||||||
|
tinymce.get('testo_buono').setContent('');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response.text().then(text => {
|
||||||
|
alert("Errore nel salvataggio: " + text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
alert("Errore di rete: " + err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// quando l'utente clicca OK sulla modale, vai alla Index
|
||||||
|
document.getElementById('modalOkBtn').addEventListener('click', function () {
|
||||||
|
window.location.href = '@Url.Action("Index")';
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,61 +10,113 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form asp-action="Edit" enctype="multipart/form-data">
|
<form id="editForm" asp-action="Edit" enctype="multipart/form-data">
|
||||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
@Html.HiddenFor(x => x.azienda)
|
@Html.HiddenFor(x => x.azienda)
|
||||||
@Html.HiddenFor(x => x.url_logo)
|
@Html.HiddenFor(x => x.url_logo)
|
||||||
@Html.HiddenFor(x => x.logo)
|
@Html.HiddenFor(x => x.logo)
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="tecnico" class="agy-client-quote"></label></h5>
|
<h5><label asp-for="tecnico"></label></h5>
|
||||||
@Html.DropDownListFor(x => x.tecnico, (IEnumerable<SelectListItem>)ViewBag.AllTecnici, new { @class = "form-control" })
|
@Html.DropDownListFor(x => x.tecnico, (IEnumerable<SelectListItem>)ViewBag.AllTecnici, new { @class = "form-control" })
|
||||||
<span asp-validation-for="tecnico" class="text-danger"></span>
|
<span asp-validation-for="tecnico" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="ragsoc" class="agy-client-quote"></label></h5>
|
<h5><label asp-for="ragsoc"></label></h5>
|
||||||
<input asp-for="ragsoc" class="form-control" />
|
<input asp-for="ragsoc" class="form-control" />
|
||||||
<span asp-validation-for="ragsoc" class="text-danger"></span>
|
<span asp-validation-for="ragsoc" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="logo" class="agy-client-quote"></label></h5>
|
<h5><label asp-for="logo"></label></h5>
|
||||||
@{
|
@{
|
||||||
byte[] appo = Model.logo;
|
if (Model.logo != null && Model.logo.Length > 0)
|
||||||
var base64 = Convert.ToBase64String(appo);
|
{
|
||||||
var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
|
var base64 = Convert.ToBase64String(Model.logo);
|
||||||
|
var imgSrc = $"data:image/png;base64,{base64}";
|
||||||
|
<img src="@imgSrc" height="80" class="mb-2" />
|
||||||
|
}
|
||||||
}
|
}
|
||||||
<img src="@imgSrc" height="80" />
|
|
||||||
<input type="file" asp-for="logo2" />
|
<input type="file" asp-for="logo2" />
|
||||||
<span asp-validation-for="logo" class="text-danger"></span>
|
<span asp-validation-for="logo" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5><label asp-for="testo_buono" class="agy-client-quote"></label></h5>
|
<h5><label asp-for="testo_buono"></label></h5>
|
||||||
<textarea asp-for="testo_buono" class="form-control"></textarea>
|
<textarea asp-for="testo_buono" id="testo_buono" class="form-control"></textarea>
|
||||||
<span asp-validation-for="testo_buono" class="text-danger"></span>
|
<span asp-validation-for="testo_buono" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
|
<div class="form-group mt-3">
|
||||||
<input type="submit" value="Salva" class="agy-btn submitForm" />
|
<input type="submit" value="Salva" class="agy-btn submitForm" />
|
||||||
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
|
<a asp-action="Index" class="agy-btn submitForm">Torna alla lista</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
</div>
|
||||||
@* <a asp-action="Index">Back to List</a> *@
|
</div>
|
||||||
|
|
||||||
|
<!-- TinyMCE -->
|
||||||
|
<script src="~/js/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
|
||||||
|
|
||||||
|
<!-- ✅ Dialog identica a quella della Create -->
|
||||||
|
<div class="modal fade" id="saveModal" tabindex="-1" role="dialog" aria-labelledby="saveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="saveModalLabel">Dati salvati</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
I dati salvati non saranno visibili nell'app finché non effettuerai il logout.
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" id="modalOkBtn">OK</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="~/js/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
@{
|
||||||
|
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||||
|
}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
tinymce.init({
|
tinymce.init({
|
||||||
selector: 'textarea#testo_buono'
|
selector: 'textarea#testo_buono',
|
||||||
|
height: 300,
|
||||||
|
menubar: false,
|
||||||
|
plugins: 'lists link table code',
|
||||||
|
toolbar: 'undo redo | bold italic | bullist numlist | link table | code'
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('editForm').addEventListener('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
tinymce.triggerSave();
|
||||||
|
|
||||||
|
const form = e.target;
|
||||||
|
const formData = new FormData(form);
|
||||||
|
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
// ✅ Mostra la stessa dialog della Create
|
||||||
|
$('#saveModal').modal('show');
|
||||||
|
} else {
|
||||||
|
alert("Errore durante il salvataggio.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('modalOkBtn').addEventListener('click', function () {
|
||||||
|
window.location.href = '@Url.Action("Index")';
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,11 +7,12 @@
|
|||||||
},
|
},
|
||||||
"ApplicationInsights": {
|
"ApplicationInsights": {
|
||||||
|
|
||||||
////PRODUZIONE
|
//PRODUZIONE
|
||||||
"rootUrlApi": "https://api-vt.poloinformatico.it/api/Polo/",
|
"rootUrlApi": "https://api-vt.poloinformatico.it/api/Polo/",
|
||||||
"rootUrlApi2": "https://api-vt.poloinformatico.it/VIRTU/",
|
"rootUrlApi2": "https://api-vt.poloinformatico.it/VIRTU/",
|
||||||
//"rootWebLoghi": "C:\\ZAPIPOLO\\api_polo\\wwwroot\\VIRTU\\",
|
//"rootWebLoghi": "C:\\ZAPIPOLO\\api_polo\\wwwroot\\VIRTU\\",
|
||||||
"rootWebLoghi": "/zucchetti/api/api-vt.poloinformatico.it/app/wwwroot/VIRTU/",
|
//"rootWebLoghi": "/zucchetti/api/api-vt.poloinformatico.it/app/wwwroot/VIRTU/",
|
||||||
|
"rootWebLoghi": "./wwwroot/VIRTU",
|
||||||
"rootUrl": "https://virtualtask.it/",
|
"rootUrl": "https://virtualtask.it/",
|
||||||
"rootPath": "/mnt/storagebox",
|
"rootPath": "/mnt/storagebox",
|
||||||
|
|
||||||
@ -21,10 +22,11 @@
|
|||||||
//"rootWebLoghi": "C:\\Users\\audif\\source\\repos\\VirtualTask\\wwwroot\\VIRTU\\",
|
//"rootWebLoghi": "C:\\Users\\audif\\source\\repos\\VirtualTask\\wwwroot\\VIRTU\\",
|
||||||
//"rootUrl": "https://localhost:7140/",
|
//"rootUrl": "https://localhost:7140/",
|
||||||
|
|
||||||
//MICHELE: PUNTAMENTO A MIO PC PER FARE I TEST
|
////MICHELE: PUNTAMENTO A MIO PC PER FARE I TEST
|
||||||
//"rootUrlApi": "https://localhost:7068/api/Polo/",
|
//"rootUrlApi": "https://localhost:7068/api/Polo/",
|
||||||
//"rootUrlApi2": "https://localhost:7068//VIRTU/",
|
//"rootUrlApi2": "https://localhost:7068//VIRTU/",
|
||||||
//"rootWebLoghi": "C:\\Users\\audif\\source\\repos\\VirtualTask\\wwwroot\\VIRTU\\",
|
////"rootWebLoghi": "C:\\Users\\audif\\source\\repos\\VirtualTask\\wwwroot\\VIRTU\\",
|
||||||
|
//"rootWebLoghi": "/zucchetti/api/api-vt.poloinformatico.it/app/wwwroot/VIRTU/",
|
||||||
//"rootUrl": "https://localhost:7068/",
|
//"rootUrl": "https://localhost:7068/",
|
||||||
|
|
||||||
"mittenteMail": "info@virtualtask.it",
|
"mittenteMail": "info@virtualtask.it",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user