Michele: Modifica massiva destinazioni
This commit is contained in:
parent
1294e6026f
commit
eedee586ec
@ -278,8 +278,10 @@ namespace SoftwayWeb.Controllers
|
||||
{
|
||||
id = model.serialeGiro,
|
||||
codAutista = model.CodAutista,
|
||||
nomeAutista = model.Autista,
|
||||
dataGiro = model.DataCarico,
|
||||
codMezzo = model.CodAutomezzo
|
||||
codMezzo = model.CodAutomezzo,
|
||||
desMezzo = model.DescAutomezzo
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
@ -105,8 +105,6 @@ namespace SoftwayWeb.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IActionResult Create(bool sel)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
@ -253,7 +251,8 @@ namespace SoftwayWeb.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult ModificaTutteDestinazioni(string id, string? codAutista, string? nomeAutista, string? codMezzo, string? nomeMezzo, DateTime dataGiroCons)
|
||||
[HttpGet]
|
||||
public IActionResult ModificaTutteDestinazioni(string id, string? codAutista, string? nomeAutista, string? codMezzo, string? nomeMezzo, DateTime dataGiroCons, int? page = 1)
|
||||
{
|
||||
helper = new SessionHelper(this);
|
||||
|
||||
@ -268,9 +267,8 @@ namespace SoftwayWeb.Controllers
|
||||
ViewBag.Autista = nomeAutista;
|
||||
ViewBag.CodMezzo = codMezzo;
|
||||
ViewBag.Mezzo = nomeMezzo;
|
||||
ViewBag.DataGiroCons = dataGiroCons; //da togliere da commento dopo che marco ha modificato e avrò la data come parametro.
|
||||
//per ora la data la passo a mano come -> 30/05/2023
|
||||
//dataGiroCons = new DateTime(2023,05,30);
|
||||
ViewBag.DataGiroCons = dataGiroCons;
|
||||
|
||||
string dataGiroString = dataGiroCons.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'");
|
||||
|
||||
urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzo";
|
||||
@ -280,6 +278,15 @@ namespace SoftwayWeb.Controllers
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
List<Destinazioni_Out> modelList = new List<Destinazioni_Out>();
|
||||
|
||||
List<SelectListItem> autisti = new List<SelectListItem>();
|
||||
autisti = getAutisti();
|
||||
ViewBag.Autisti = autisti;
|
||||
|
||||
List<SelectListItem> mezzi = new List<SelectListItem>();
|
||||
mezzi = getMezzi();
|
||||
ViewBag.Mezzi = mezzi;
|
||||
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
@ -288,11 +295,81 @@ namespace SoftwayWeb.Controllers
|
||||
modelList = JsonConvert.DeserializeObject<List<Destinazioni_Out>>(dato);
|
||||
modelList = modelList.Where(x => x.serialeGiro.Equals(id.TrimEnd())).ToList();
|
||||
|
||||
}
|
||||
//if (page != null && page < 1)
|
||||
//{
|
||||
// page = 1;
|
||||
//}
|
||||
|
||||
return View(modelList);
|
||||
//var pageSize = 10;
|
||||
|
||||
//var shortList = modelList.ToPagedList(/*page ?? 1, pageSize*/);
|
||||
|
||||
return View(modelList);
|
||||
}
|
||||
else
|
||||
{
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", errMes);
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
//return View(modelList);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult ModificaTutteDestinazioniPost(List<Destinazioni_Out> modelList, string? autisti, /*string? nomeAutista,*/ string? mezzi)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
|
||||
token = helper.GetStringValue("tok");
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Login", "Login");
|
||||
}
|
||||
|
||||
foreach (var destinazione in modelList)
|
||||
{
|
||||
Modgir mg = new Modgir();
|
||||
|
||||
mg.Piserial = destinazione.Brserial;
|
||||
mg.Pidata = destinazione.DataCarico;
|
||||
mg.Picommit = destinazione.CodCommittente;
|
||||
mg.Pidesdiv = destinazione.CodSede;
|
||||
mg.Pitarga = mezzi.TrimEnd();
|
||||
mg.Piautist = autisti.TrimEnd();
|
||||
mg.Pitiprec = "M";
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
|
||||
urlBase = apiUrl + "ModificaGiro/addModgir";
|
||||
|
||||
Uri 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)
|
||||
//{
|
||||
// //Destinazioni_Out destMod = new Destinazioni_Out();
|
||||
// //destMod.serialeGiro = destinazione.Brserial;
|
||||
// //destMod.CodAutista = destinazione.CodAutista;
|
||||
// //destMod.CodAutomezzo = destinazione.CodAutomezzo;
|
||||
// //new
|
||||
// //{
|
||||
// // id = destinazione.serialeGiro,
|
||||
// // codAutista = destinazione.CodAutista,
|
||||
// // dataGiro = destinazione.DataCarico,
|
||||
// // codMezzo = destinazione.CodAutomezzo
|
||||
// //},;
|
||||
//}
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Giri");
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public IActionResult Create(GiriConsegnaView model)
|
||||
@ -320,7 +397,6 @@ namespace SoftwayWeb.Controllers
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
@ -329,6 +405,8 @@ namespace SoftwayWeb.Controllers
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e });
|
||||
}
|
||||
|
||||
#region METODI PRIVATI
|
||||
|
||||
private List<SelectListItem> getAutisti()
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
@ -432,5 +510,7 @@ namespace SoftwayWeb.Controllers
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
|
||||
#endregion METODI PRIVATI
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Bancali";
|
||||
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||
}
|
||||
|
||||
<!-- Basic Layout -->
|
||||
|
||||
@ -41,8 +41,8 @@
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<a href="@Url.ActionLink("Index", "Destinazioni", new { id="", codAutista=lst[i].CodAutista, dataGiro=lst[i].DataGiro, codMezzo=lst[i].CodMezzo })" title="Destinazioni" class="links"><img alt="nocons" src="@Url.Content("~/images/icons8-oggetti-puntiforme-30.png")" style="width:24px;height:24px;"></a>
|
||||
</td>
|
||||
<a href="@Url.ActionLink("Index", "Destinazioni", new { id="", codAutista=lst[i].CodAutista, nomeAutista=lst[i].Autista, dataGiro=lst[i].DataGiro, codMezzo=lst[i].CodMezzo, desMezzo=lst[i].Automezzo})" title="Destinazioni" class="links"><img alt="nocons" src="@Url.Content("~/images/icons8-oggetti-puntiforme-30.png")" style="width:24px;height:24px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
@ -1,223 +1,143 @@
|
||||
@* @model IEnumerable<SoftwayWeb.Models.Destinazioni_Out> *@
|
||||
@model IPagedList<SoftwayWeb.Models.Destinazioni_Out>
|
||||
@using X.PagedList;
|
||||
@using X.PagedList.Mvc.Core;
|
||||
@using X.PagedList;
|
||||
@model List<SoftwayWeb.Models.Destinazioni_Out>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ModificaTutteDestinazioni";
|
||||
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||
List<Destinazioni_Out> modelList = new List<Destinazioni_Out>();
|
||||
modelList = Model;
|
||||
}
|
||||
|
||||
<h1>Modifica Tutte Destinazioni</h1>
|
||||
|
||||
<div>
|
||||
<p>Autista da sostituire: @ViewBag.CodAutista - @ViewBag.Autista</p>
|
||||
<p>Automezzo da sostituire: @ViewBag.CodMezzo - @ViewBag.Mezzo</p>
|
||||
<p><b>Autista da sostituire:</b> @ViewBag.CodAutista - @ViewBag.Autista</p>
|
||||
<p><b>Automezzo da sostituire:</b> @ViewBag.CodMezzo - @ViewBag.Mezzo</p>
|
||||
</div>
|
||||
|
||||
@* <div>@Html.DropDownList("codAutista", ViewBag.Autisti, null, new { @class = "agy-form-field require" })</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<th><b>Automezzo:</b></th>
|
||||
<div>@Html.DropDownList("codMezzo", ViewBag.CodMezzo, null, new { @class = "agy-form-field require" })</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div> *@
|
||||
@using (Html.BeginForm("ModificaTutteDestinazioniPost", "Giri", FormMethod.Post))
|
||||
{
|
||||
<th><b>Seleziona il nuovo autista:</b></th>
|
||||
<div>@Html.DropDownList("autisti", ViewBag.Autisti, null, new { @class = "agy-form-field require" })</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
|
||||
<th><b>Seleziona il nuovo Automezzo:</b></th>
|
||||
<div>@Html.DropDownList("mezzi", ViewBag.Mezzi, null, new { @class = "agy-form-field require" })</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
|
||||
@* <div class="form-group">
|
||||
<input type="submit" value="Salva modifiche" class="btn btn-primary" />
|
||||
</div> *@
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Seq</th>
|
||||
<th>Committente</th>
|
||||
<th>Sede</th>
|
||||
<th>Indirizzo sede</th>
|
||||
<th>Casse</th>
|
||||
<th>Trasf.</th>
|
||||
<th>Colli</th>
|
||||
<th>Nr.Cons.</th>
|
||||
<th>Uova</th>
|
||||
<th>Cist</th>
|
||||
<th>Note</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
||||
</tr>
|
||||
@* <tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CodAutomezzo)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DescAutomezzo)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Brserial)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DataCarico)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CodCommittente)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Committente)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CodAutista)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Autista)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CodSede)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Sede)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.IndirizzoSede)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Cproword)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Cprownum)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Brmerce)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Brnote)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.ImportoDaRitirare)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.ItemList)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.serialeGiro)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Casse)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Trasf)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Colli)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.num_cons)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Uova)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Cist)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Seq)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Prog)
|
||||
</th>
|
||||
<th></th> *@
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var item in Model) {
|
||||
@for(var i = 0; i < modelList.Count(); i++)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CodAutomezzo)
|
||||
@Html.HiddenFor(modelItem => modelList[i].CodAutomezzo)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DescAutomezzo)
|
||||
@Html.HiddenFor(modelItem => modelList[i].DescAutomezzo)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Brserial)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Brserial)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DataCarico)
|
||||
@Html.HiddenFor(modelItem => modelList[i].DataCarico)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CodCommittente)
|
||||
@Html.HiddenFor(modelItem => modelList[i].CodCommittente)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Committente)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Committente)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CodAutista)
|
||||
@Html.HiddenFor(modelItem => modelList[i].CodAutista)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Autista)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Autista)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CodSede)
|
||||
@Html.HiddenFor(modelItem => modelList[i].CodSede)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sede)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Sede)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.IndirizzoSede)
|
||||
@Html.HiddenFor(modelItem => modelList[i].IndirizzoSede)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cproword)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Cproword)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cprownum)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Cprownum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Brmerce)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Brmerce)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Brnote)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Brnote)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ImportoDaRitirare)
|
||||
@Html.HiddenFor(modelItem => modelList[i].ImportoDaRitirare)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ItemList)
|
||||
@Html.HiddenFor(modelItem => modelList[i].ItemList)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.serialeGiro)
|
||||
@Html.HiddenFor(modelItem => modelList[i].serialeGiro)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Casse)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Casse)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Trasf)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Trasf)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Colli)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Colli)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.num_cons)
|
||||
@Html.HiddenFor(modelItem => modelList[i].num_cons)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Uova)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Uova)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cist)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Cist)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Note)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Note)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Seq)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Seq)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Prog)
|
||||
@Html.HiddenFor(modelItem => modelList[i].Prog)
|
||||
</td>
|
||||
<td>
|
||||
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
|
||||
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
|
||||
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Salva modifiche" class="btn btn-primary" />
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
@* <br />
|
||||
<nav>
|
||||
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, Model/* searchString = @ViewData["CurrentFilter"] */ }), new PagedListRenderOptions()
|
||||
{
|
||||
ActiveLiElementClass = "active",
|
||||
PageClasses = new[] { "page-link" },
|
||||
LiElementClasses = new[] { "page-item" },
|
||||
UlElementClasses = new[] { "pagination", "justify-content-center", "mt-3" },
|
||||
LinkToNextPageFormat = "Successiva",
|
||||
LinkToPreviousPageFormat = "Precedente",
|
||||
MaximumPageNumbersToDisplay = 5,
|
||||
DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
|
||||
DisplayLinkToNextPage = PagedListDisplayMode.Always
|
||||
})
|
||||
</nav> *@
|
||||
Loading…
Reference in New Issue
Block a user