lista con checkbox
This commit is contained in:
parent
9f15748ac6
commit
2b536cc7dd
@ -80,11 +80,57 @@ namespace SoftwayWeb.Controllers
|
|||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
SessionHelper helper = new SessionHelper(this);
|
SessionHelper helper = new SessionHelper(this);
|
||||||
ViewBag.Autisti = getAutisti();
|
List<GiriConsegnaDaCreare> modelList = new List<GiriConsegnaDaCreare>();
|
||||||
ViewBag.NuoviGiri = getNuoviGiri();
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
return View();
|
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);
|
||||||
|
}
|
||||||
|
//ViewBag.Autisti = getAutisti();
|
||||||
|
//ViewBag.NuoviGiri = getNuoviGiri();
|
||||||
|
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]
|
[HttpPost]
|
||||||
public IActionResult Create(GiriConsegnaView model)
|
public IActionResult Create(GiriConsegnaView model)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,5 +11,7 @@ namespace SoftwayWeb.Models
|
|||||||
|
|
||||||
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
|
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
|
||||||
public DateTime? DataGiro { get; set; }
|
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";
|
ViewData["Title"] = "Create";
|
||||||
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||||
|
List<GiriConsegnaDaCreare> lst = new List<GiriConsegnaDaCreare>();
|
||||||
|
lst = Model;
|
||||||
}
|
}
|
||||||
<div class="agy-project-wrapper agy-project-page-wrapper">
|
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -50,9 +52,11 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<table class="table">
|
@* <table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
<th>Data</th>
|
<th>Data</th>
|
||||||
<th>Autista</th>
|
<th>Autista</th>
|
||||||
<th>Automezzo</th>
|
<th>Automezzo</th>
|
||||||
@ -61,14 +65,86 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var person in ViewBag.NuoviGiri)
|
@foreach (var person in ViewBag.NuoviGiri)
|
||||||
{
|
{
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
<td> </td>
|
||||||
<td>@person.DataGiro.ToString("dd/MM/yyyy")</td>
|
<td>@person.DataGiro.ToString("dd/MM/yyyy")</td>
|
||||||
<td>@person.CodAutista - @person.Autista</td>
|
<td>@person.CodAutista - @person.Autista</td>
|
||||||
<td>@person.CodAutomezzo - @person.Automezzo</td>
|
<td>@person.CodAutomezzo - @person.Automezzo</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>*@
|
||||||
|
|
||||||
|
@* @using (Html.BeginForm("PostIndex", "Giri", FormMethod.Post))
|
||||||
|
{*@
|
||||||
|
<form asp-action="PostIndex">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th>Data</th>
|
||||||
|
<th>Autista</th>
|
||||||
|
<th>Automezzo</th>
|
||||||
|
</tr>
|
||||||
|
</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].CodAutomezzo)-@Html.DisplayFor(a=>lst[i].Automezzo)
|
||||||
|
@Html.HiddenFor(a=>lst[i].CodAutomezzo)
|
||||||
|
|
||||||
|
</td>
|
||||||
|
@Html.HiddenFor(a=>lst[i].Automezzo)
|
||||||
|
@Html.HiddenFor(a=>lst[i].Autista)
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
|
||||||
|
@* @for (var i = 0; i < lst.Count(); i++)
|
||||||
|
{
|
||||||
|
string a = lst[i].CodAutista;
|
||||||
|
string d = lst[i].DataGiro.Value.ToString("dd/MM/yyyy");
|
||||||
|
string m = lst[i].CodAutomezzo;
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.CheckBoxFor(m => [i].Selected);
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@d
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@a
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@m
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}*@
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user