Merge branch 'master' of 10.0.0.83:/usr/local/git/SoftwayWeb
This commit is contained in:
commit
499e8791c5
@ -85,14 +85,66 @@ namespace SoftwayWeb.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult Create()
|
||||
|
||||
|
||||
public IActionResult Create(bool sel)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
ViewBag.Autisti = getAutisti();
|
||||
ViewBag.NuoviGiri = getNuoviGiri();
|
||||
return View();
|
||||
List<GiriConsegnaDaCreare> modelList = new List<GiriConsegnaDaCreare>();
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
urlBase = apiUrl + "Giri/listaGiriDaCreare";
|
||||
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
modelList = JsonConvert.DeserializeObject<List<GiriConsegnaDaCreare>>(data);
|
||||
}
|
||||
|
||||
foreach(GiriConsegnaDaCreare giro in modelList)
|
||||
{
|
||||
giro.IsSelected= sel;
|
||||
}
|
||||
|
||||
return View(modelList);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult PostIndex(IList<GiriConsegnaDaCreare> lst)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
foreach(GiriConsegnaDaCreare g in lst)
|
||||
{
|
||||
if(g.IsSelected==true)
|
||||
{
|
||||
//ViewBag.Autisti = getAutisti();
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
urlBase = apiUrl + "Giri/addGiro2";
|
||||
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
string data = JsonConvert.SerializeObject(g);
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", errMes);
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
return RedirectToAction("Index", "Giri");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Create(GiriConsegnaView model)
|
||||
{
|
||||
|
||||
@ -4,12 +4,14 @@ namespace SoftwayWeb.Models
|
||||
{
|
||||
public class GiriConsegnaDaCreare
|
||||
{
|
||||
public string? CodAutomezzo { get; set; }
|
||||
public string? CodMezzo { get; set; }
|
||||
public string? CodAutista { get; set; }
|
||||
public string? Autista { get; set; }
|
||||
public string? Automezzo { get; set; }
|
||||
|
||||
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
|
||||
public DateTime? DataGiro { get; set; }
|
||||
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
@model SoftwayWeb.Models.GiriConsegnaView
|
||||
@model List<SoftwayWeb.Models.GiriConsegnaDaCreare>
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||
List<GiriConsegnaDaCreare> lst = new List<GiriConsegnaDaCreare>();
|
||||
lst = Model;
|
||||
}
|
||||
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||
<div class="container">
|
||||
@ -50,25 +52,56 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Autista</th>
|
||||
<th>Automezzo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var person in ViewBag.NuoviGiri)
|
||||
{
|
||||
|
||||
<form asp-action="PostIndex">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>@person.DataGiro.ToString("dd/MM/yyyy")</td>
|
||||
<td>@person.CodAutista - @person.Autista</td>
|
||||
<td>@person.CodAutomezzo - @person.Automezzo</td>
|
||||
<th> </th>
|
||||
<th>Data</th>
|
||||
<th>Autista</th>
|
||||
<th>Automezzo</th>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (var i = 0; i < lst.Count(); i++)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.CheckBoxFor(a=>lst[i].IsSelected)
|
||||
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(a=>lst[i].DataGiro)
|
||||
@Html.HiddenFor(a=>lst[i].DataGiro)
|
||||
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(a=>lst[i].CodAutista)-@Html.DisplayFor(a=>lst[i].Autista)
|
||||
@Html.HiddenFor(a=>lst[i].CodAutista)
|
||||
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(a=>lst[i].CodMezzo)-@Html.DisplayFor(a=>lst[i].Automezzo)
|
||||
@Html.HiddenFor(a=>lst[i].CodMezzo)
|
||||
|
||||
</td>
|
||||
@Html.HiddenFor(a=>lst[i].Automezzo)
|
||||
@Html.HiddenFor(a=>lst[i].Autista)
|
||||
|
||||
</tr>
|
||||
}
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
@Html.ActionLink("Seleziona tutti", "Create", "Giri",new { sel = true }, null)
|
||||
|
||||
@Html.ActionLink("Deleziona tutti", "Create", "Giri",new { sel = false }, null)
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
@Html.DisplayFor(modelItem => item.CodAutista) - @Html.DisplayFor(modelItem => item.Autista)
|
||||
</td>
|
||||
<td>
|
||||
@Html.HiddenFor(modelItem => item.CodMezzo) - @Html.HiddenFor(modelItem => item.Automezzo)
|
||||
@Html.DisplayFor(modelItem => item.CodMezzo) - @Html.DisplayFor(modelItem => item.Automezzo)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.BancaliCaricati)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user