elimina destinazione

This commit is contained in:
Marco Audiffredi 2024-07-15 12:40:52 +02:00
parent bca6fc6522
commit 0af27bd7da
4 changed files with 85 additions and 6 deletions

View File

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using SoftwayWeb.Models;
using System.Diagnostics;
using System.Text;
using X.PagedList;
@ -97,14 +98,14 @@ namespace SoftwayWeb.Controllers
}
[HttpPost]
public IActionResult EliminaDestinazione(string seriale)
public IActionResult EliminaDestinazione(string serial)
{
SessionHelper helper = new SessionHelper(this);
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/listaDestinazioniBySerial";
urlBase = urlBase + "?seriale=" + seriale;
urlBase = apiUrl + "Giri/listaDestinazioneBySerial";
urlBase = urlBase + "?seriale=" + serial;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
@ -118,6 +119,33 @@ namespace SoftwayWeb.Controllers
model = JsonConvert.DeserializeObject<Destinazioni_Out>(dato);
//qui metodo post per scrivere su pimodgir
Modgir mg=new Modgir();
mg.Piserial = model.Brserial;
mg.Pidata = model.DataCarico;
mg.Picommit = model.CodCommittente;
mg.Pidesdiv = model.CodSede;
mg.Pitarga = model.CodAutomezzo;
mg.Piautist = model.CodAutista;
mg.Pitiprec = "D";
urlBase = apiUrl + "ModificaGiro/addModgir";
baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
string data = JsonConvert.SerializeObject(mg);
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
HttpResponseMessage response2 = client.PostAsync(baseAddress, content).Result;
if (response2.IsSuccessStatusCode)
{
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
}
else
{
@ -126,7 +154,21 @@ namespace SoftwayWeb.Controllers
return RedirectToAction("Error");
}
return RedirectToAction("Index", "Giri");
return RedirectToAction("Index", "Destinazioni", new
{
id = model.Brserial,
codAutista = model.CodAutista,
dataGiro = model.DataCarico,
codMezzo=model.CodAutomezzo
});
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
SessionHelper helper = new SessionHelper(this);
string e = helper.GetStringValue("errMsg");
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e });
}
}
}

15
Models/Modgir.cs Normal file
View File

@ -0,0 +1,15 @@
namespace SoftwayWeb.Models
{
public class Modgir
{
public string? Piprogre { get; set; }
public string? Piserial { get; set; }
public DateTime? Pidata { get; set; }
public string? Picommit { get; set; }
public string? Pidesdiv { get; set; }
public string? Pitarga { get; set; }
public string? Piautist { get; set; }
public string? Pitiprec { get; set; }
public string? Pirigele { get; set; }
}
}

22
Models/Modgir_out.cs Normal file
View File

@ -0,0 +1,22 @@
namespace SoftwayWeb.Models
{
public class Modgir_out
{
public string? Piprogre { get; set; }
public string? Piserial { get; set; }
public DateTime? Pidata { get; set; }
public string? Picommit { get; set; }
public string? Pidesdiv { get; set; }
public string? Pitarga { get; set; }
public string? Piautist { get; set; }
public string? Pitiprec { get; set; }
public string? Pirigele { get; set; }
/// <summary>errore titolo</summary>
public string? err_title { get; set; }
/// <summary>errore dettaglio</summary>
public string? err_detail { get; set; }
/// <summary>errore status code (200, 500)</summary>
public string? err_status_code { get; set; }
}
}

View File

@ -137,7 +137,7 @@
@Html.DisplayFor(modelItem => item.Note)
</td>
<td>
<a href="@Url.ActionLink("EliminaDestinazione", "Destinazioni", new { id=item.Brserial })" title="Bancali" class="links"><img alt="nocons" src="@Url.Content("~/images/icons8-rimuovere-24.png")" style="width:24px;height:24px;"></a>
<a href="@Url.ActionLink("EliminaDestinazione", "Destinazioni", new { serial=item.Brserial })" title="Bancali" class="links"><img alt="nocons" src="@Url.Content("~/images/icons8-rimuovere-24.png")" style="width:24px;height:24px;"></a>
</td>