Michele: Creazione nuove destinazioni
This commit is contained in:
parent
bae628ed8e
commit
62f27ce021
@ -37,13 +37,18 @@ namespace SoftwayWeb.Controllers
|
||||
{
|
||||
return RedirectToAction("Login", "Login");
|
||||
}
|
||||
|
||||
Modgir model = new Modgir();
|
||||
|
||||
ViewBag.serialeGiro = serialeGiro;
|
||||
model.Pisergir = serialeGiro;
|
||||
ViewBag.Commit = getCommittenti();
|
||||
ViewBag.CodAutista = getAutisti();
|
||||
ViewBag.Mezzi = getMezzi();
|
||||
|
||||
return View();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public IActionResult NewDestinazione(Modgir modgir)
|
||||
public IActionResult NewDestinazione(Modgir modgir, string? autista, string? mezzo, string id)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
|
||||
@ -56,17 +61,17 @@ namespace SoftwayWeb.Controllers
|
||||
|
||||
//qui metodo post per scrivere su pimodgir
|
||||
Modgir mg = new Modgir();
|
||||
|
||||
mg.Piprogre = modgir.Piprogre;
|
||||
mg.Piserial = modgir.Piserial;
|
||||
|
||||
//mg.Piprogre = modgir.Piprogre;
|
||||
mg.Piserial = string.Empty;
|
||||
mg.Pidata = modgir.Pidata;
|
||||
mg.Picommit = modgir.Picommit;
|
||||
mg.Pidesdiv = modgir.Pidesdiv;
|
||||
mg.Pitarga = modgir.Pitarga;
|
||||
mg.Piautist = modgir.Piautist;
|
||||
mg.Pitiprec = "M";
|
||||
mg.Pirigele = modgir.Pirigele;
|
||||
mg.Pisergir = modgir.Pisergir;
|
||||
mg.Pitarga = mezzo.TrimEnd();
|
||||
mg.Piautist = autista.TrimEnd();
|
||||
mg.Pitiprec = "A";
|
||||
mg.Pirigele = string.Empty;
|
||||
mg.Pisergir = id;
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
|
||||
@ -81,7 +86,6 @@ namespace SoftwayWeb.Controllers
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return RedirectToAction("Index","Giri");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -140,7 +144,90 @@ namespace SoftwayWeb.Controllers
|
||||
return selectItems;
|
||||
}
|
||||
|
||||
private List<SelectListItem> getAutisti()
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
urlBase = apiUrl + "Giri/listaAutisti";
|
||||
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
List<SelectListItem> selectItems = new List<SelectListItem>();
|
||||
List<Personale> modelList = new List<Personale>();
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
modelList = JsonConvert.DeserializeObject<List<Personale>>(data);
|
||||
|
||||
//per gestire primo elemento tendina (deve essere vuoto)
|
||||
SelectListItem listItemFirt = new SelectListItem();
|
||||
|
||||
listItemFirt.Value = string.Empty;
|
||||
listItemFirt.Text = " - Seleziona autista";
|
||||
selectItems.Add(listItemFirt);
|
||||
|
||||
foreach (var role in modelList)
|
||||
{
|
||||
SelectListItem listItem = new SelectListItem();
|
||||
//string s = role.Catcodice + " - " + role.Catnome;
|
||||
string s = role.Catnome + " - " + role.Catcodice; // 25/07/2024 invertito nome autista con codice autista
|
||||
listItem.Value = role.Catcodice;
|
||||
listItem.Text = s;
|
||||
selectItems.Add(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
return selectItems;
|
||||
}
|
||||
|
||||
private List<SelectListItem> getMezzi()
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
urlBase = apiUrl + "Giri/listaAutomezzi";
|
||||
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
List<SelectListItem> selectItems = new List<SelectListItem>();
|
||||
List<Automezzi> listMezzi = new List<Automezzi>();
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
listMezzi = JsonConvert.DeserializeObject<List<Automezzi>>(data);
|
||||
|
||||
listMezzi = listMezzi.OrderBy(x => x.CauTarga).ToList();
|
||||
|
||||
//per gestire primo elemento tendina (deve essere vuoto)
|
||||
SelectListItem listItemFirt = new SelectListItem();
|
||||
|
||||
listItemFirt.Value = string.Empty;
|
||||
listItemFirt.Text = " - Seleziona automezzo";
|
||||
selectItems.Add(listItemFirt);
|
||||
|
||||
foreach (var mezzo in listMezzi)
|
||||
{
|
||||
SelectListItem listItem = new SelectListItem();
|
||||
List<SelectListItem> listItemOrderby = new List<SelectListItem>();
|
||||
string s = mezzo.CauTarga + " - " + mezzo.CauDesc;
|
||||
listItem.Value = mezzo.CauTarga;
|
||||
listItem.Text = s;
|
||||
|
||||
selectItems.Add(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
return selectItems;
|
||||
|
||||
}
|
||||
#endregion METODI INTERNI
|
||||
|
||||
#region CASCADING
|
||||
@ -153,7 +240,7 @@ namespace SoftwayWeb.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Cascading(string Picommit/*ancodice*/)
|
||||
public IActionResult Cascading(string Picommit/*ancodice*/)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
Cascading model = new Cascading();
|
||||
@ -201,6 +288,8 @@ namespace SoftwayWeb.Controllers
|
||||
}
|
||||
}
|
||||
return Json(new SelectList(model.SediCons, "Value", "Text"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion CASCADING
|
||||
|
||||
@ -3,20 +3,26 @@
|
||||
@{
|
||||
ViewData["Title"] = "AddDestinazione";
|
||||
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||
@ViewBag.SediCons
|
||||
List<SelectListItem> listItems = new List<SelectListItem>();
|
||||
listItems = ViewBag.Commit;
|
||||
List<SelectListItem> listItems2 = new List<SelectListItem>();
|
||||
listItems2 = ViewBag.SediCons;
|
||||
|
||||
|
||||
}
|
||||
|
||||
<h1>Aggiungi una nuova destinazione</h1>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">Nuova destinazione</h5> <small class="text-muted float-end"></small>
|
||||
</div>
|
||||
@* @using (Html.BeginForm("AddDestinazione", "AddDestinazione", FormMethod.Post))
|
||||
{ *@
|
||||
|
||||
@using (Html.BeginForm("NewDestinazione", "AddDestinazione", FormMethod.Post))
|
||||
{
|
||||
@* <div class="mb-3">
|
||||
<b>Seleziona il Committente: </b>@Html.DropDownListFor(x => x.Picommit, (IEnumerable<SelectListItem>)ViewBag.Commit, new { @id = "ddlCommittenti", @class = "agy-form-field require" }) *@
|
||||
@* @Html.DropDownList("Committente", ViewBag.Committente, null, new { @class = "agy-form-field require" }) *@
|
||||
@ -27,7 +33,7 @@
|
||||
@* </div> *@
|
||||
|
||||
<div class="card-body">
|
||||
<form asp-action="AggiungiDestinazione">
|
||||
<form asp-action="NewDestinazione">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="mb-3">
|
||||
<b><label asp-for="Picommit" class="control-label"></label></b>
|
||||
@ -35,39 +41,45 @@
|
||||
@Html.DropDownListFor(x => x.Picommit, (IEnumerable<SelectListItem>)ViewBag.Commit, new { @id = "ddlCommittenti", @class = "agy-form-field require" })
|
||||
</div><span asp-validation-for="Picommit" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="mb-3" id="District">
|
||||
<b><label asp-for="Pidesdiv" class="control-label"></label></b>
|
||||
<div id="District">
|
||||
<div>
|
||||
@Html.DropDownListFor(x => x.Pidesdiv, new List<SelectListItem>(), "- Seleziona sede", new { @id = "ddlSediCons", @class = "agy-form-field require" })
|
||||
</div>
|
||||
<span asp-validation-for="Pidesdiv" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@* <div class="mb-3">
|
||||
<b><label asp-for="Piprogre" class="control-label"></label></b>
|
||||
<input asp-for="Piprogre" class="form-control" />
|
||||
<span asp-validation-for="Piprogre" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
</div> *@
|
||||
@* <div class="mb-3">
|
||||
<b><label asp-for="Piserial" class="control-label"></label></b>
|
||||
<input asp-for="Piserial" class="form-control" />
|
||||
<span asp-validation-for="Piserial" class="text-danger"></span>
|
||||
</div>
|
||||
</div> *@
|
||||
<div class="mb-3">
|
||||
<b><label asp-for="Pidata" class="control-label"></label></b>
|
||||
<input asp-for="Pidata" class="form-control" />
|
||||
<span asp-validation-for="Pidata" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<b><label asp-for="Pitarga" class="control-label"></label></b>
|
||||
<input asp-for="Pitarga" class="form-control" />
|
||||
<span asp-validation-for="Pitarga" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<b><label asp-for="Piautist" class="control-label"></label></b>
|
||||
<input asp-for="Piautist" class="form-control" />
|
||||
@* <input asp-for="Piautist" class="form-control" /> *@
|
||||
<div>
|
||||
@Html.DropDownList("autista",ViewBag.CodAutista, null, new { @class = "agy-form-field require" })
|
||||
</div>
|
||||
<span asp-validation-for="Piautist" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<b><label asp-for="Pitarga" class="control-label"></label></b>
|
||||
@* <input asp-for="Pitarga" class="form-control" /> *@
|
||||
<div>
|
||||
@Html.DropDownList("mezzo",ViewBag.Mezzi, null, new { @class = "agy-form-field require" })
|
||||
</div>
|
||||
<span asp-validation-for="Pitarga" class="text-danger"></span>
|
||||
</div>
|
||||
@* <div class="mb-3">
|
||||
<b><label asp-for="Pitiprec" class="control-label"></label></b>
|
||||
<input asp-for="Pitiprec" class="form-control" />
|
||||
<span asp-validation-for="Pitiprec" class="text-danger"></span>
|
||||
@ -76,23 +88,29 @@
|
||||
<b><label asp-for="Pirigele" class="control-label"></label></b>
|
||||
<input asp-for="Pirigele" class="form-control" />
|
||||
<span asp-validation-for="Pirigele" class="text-danger"></span>
|
||||
</div>
|
||||
</div> *@
|
||||
@* <div class="mb-3">
|
||||
<label class="form-label" for="basic-default-fullname"><b>@Html.DisplayNameFor(model => model.Pirigele)</b> </label>
|
||||
<div class="form-text">@Html.DisplayFor(model => model.Pirigele)</div>
|
||||
</div> *@
|
||||
<div class="mb-3">
|
||||
<b><label asp-for="Pisergir" class="control-label"></label></b>
|
||||
<input asp-for="Pisergir" class="form-control" />
|
||||
<div>
|
||||
@Html.DisplayFor(x => x.Pisergir)
|
||||
</div>
|
||||
<span asp-validation-for="Pisergir" class="text-danger"></span>
|
||||
</div>
|
||||
</div> *@
|
||||
<div>
|
||||
<input type="submit" asp-controller="AddDestinazione" asp-action="NewDestinazione" value="Salva modifiche" class="btn btn-primary" />
|
||||
@Html.HiddenFor(x => x.Piautist)
|
||||
@Html.HiddenFor(x => x.Pitarga)
|
||||
@Html.HiddenFor(x => x.Piprogre)
|
||||
@Html.HiddenFor(x => x.Piserial)
|
||||
@Html.HiddenFor(x => x.Pitiprec)
|
||||
@Html.HiddenFor(x => x.Pisergir)
|
||||
|
||||
<input type="submit" asp-action="NewDestinazione" asp-controller="AddDestinazione" asp-route-id="@Model.Pisergir" value="Salva modifiche" class="btn btn-primary" />
|
||||
<a asp-action="Index" asp-controller="Giri" value="Torna alla lista" class="btn btn-primary">Torna alla lista</a>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@* } *@
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<label>Sede consegna</label>
|
||||
</td>
|
||||
<td id="District">
|
||||
@Html.DropDownListFor(x => x.pccodsed, new List<SelectListItem>(), "--Select--", new {@id = "ddlSediCons"})
|
||||
@Html.DropDownListFor(x => x.pccodsed, Model.SediCons/* new List<SelectListItem>() */, "--Select--", new {@id = "ddlSediCons"})
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user