Michele: destinazioni - controller, index, model + GiriConsegna - aggiunta mezzo e codice mezzo su model

This commit is contained in:
michele 2024-06-27 17:22:58 +02:00
parent fb68e2461e
commit 67471ee2ac
6 changed files with 289 additions and 8 deletions

View File

@ -0,0 +1,58 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SoftwayWeb.Models;
using X.PagedList;
namespace SoftwayWeb.Controllers
{
public class DestinazioniController : Controller
{
string apiUrl = string.Empty;
string urlBase = string.Empty;
string token = string.Empty;
string errMes = string.Empty;
private readonly IConfiguration _configuration;
HttpClient client;
SessionHelper helper;
public DestinazioniController(IConfiguration configuration)
{
_configuration = configuration;
client = new HttpClient();
var key = _configuration["ApplicationInsights:rootUrlApi"];
apiUrl = key;
}
public IActionResult Index(string id, string? codAutista, DateTime dataGiro, string? codMezzo)
{
helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzo";
//dataGiro = dataGiro.ToUniversalTime();
//urlBase = urlBase + "autista=" + giro.CodAutista + "datGiro=" + giro.DataGiro;
urlBase = urlBase + "?autista=" + codAutista.Trim() + "&dataGiro=2023-05-30T00%3A00%3A00.000Z" + "&mezzo=" + codMezzo /*+ dataGiro*/;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
List<Destinazioni_Out> modelList = new List<Destinazioni_Out>();
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
if (response.IsSuccessStatusCode)
{
string dato = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Destinazioni_Out>>(dato);
modelList = modelList.Where(x => x.serialeGiro == id).ToList();
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
//var shortList = modelList.ToPagedList();
return View(modelList);
}
}
}

View File

@ -0,0 +1,68 @@
using System.ComponentModel.DataAnnotations;
namespace SoftwayWeb.Models
{
public class Destinazioni_Out
{
[Display(Name = "Cod. Automezzo")]
public string? CodAutomezzo { get; set; }
[Display(Name = "Automezzo")]
public string? DescAutomezzo { get; set; }
[Display(Name = "Seriale")]
public string? Brserial { get; set; }
[Display(Name = "Data carico")]
public DateTime? DataCarico { get; set; }
[Display(Name = "Cod. committente")]
public string? CodCommittente { get; set; }
[Display(Name = "Committente")]
public string? Committente { get; set; }
[Display(Name = "Cod. Autista")]
public string? CodAutista { get; set; }
[Display(Name = "Autista")]
public string? Autista { get; set; }
[Display(Name = "Codice sede")]
public string? CodSede { get; set; }
[Display(Name = "Sede")]
public string? Sede { get; set; }
[Display(Name = "Indirizzo")]
public string? IndirizzoSede { get; set; }
[Display(Name = "Riga")]
public int? Cproword { get; set; }
[Display(Name = "Riga")]
public int? Cprownum { get; set; }
[Display(Name = "Merce")]
public string? Brmerce { get; set; }
[Display(Name = "Note")]
public string? Brnote { get; set; }
[Display(Name = "Importo da Ritirare"), System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
public decimal? ImportoDaRitirare { get; set; }
public string? ItemList { get; set; }
public ConsegnaFatta? ConsFatta { get; set; }
[Display(Name = "Seriale Giro")]
public string? serialeGiro { get; set; }
public class ConsegnaFatta
{
[Display(Name = "Seriale consegna")]
public string? consFattaSerial { get; set; }
[Display(Name = "Riga")]
public int? consFattaRow { get; set; }
[Display(Name = "Bancali caricati")]
public int? consFattaBanCar { get; set; }
[Display(Name = "Bancali scaricati")]
public int? consFattaBanSca { get; set; }
[Display(Name = "Automezzo")]
public string? consFattaMezzo { get; set; }
[Display(Name = "Autista")]
public string? consFattaAut { get; set; }
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
public decimal? consFattaImpor { get; set; }
public string? consFattaNotImp { get; set; }
public string? consFattaNotBan { get; set; }
public string? consFattaFlagCons { get; set; }
}
}
}

View File

@ -33,5 +33,11 @@ namespace SoftwayWeb.Models
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
[Display(Name = "Data chiusura")]
public DateTime? DataChiusura { get; set; }
[Display(Name = "Cod. Mezzo")]
public string? CodMezzo { get; set; }
[Display(Name = "Automezzo")]
public string? Automezzo { get; set; }
}
}

View File

@ -0,0 +1,148 @@
@model IEnumerable<SoftwayWeb.Models.Destinazioni_Out>
@* @model SoftwayWeb.Models.Destinazioni_Out *@
@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList;
@{
ViewData["Title"] = "Index";
}
<h1>Lista destinazioni</h1>
@* <p>
<a asp-action="Create">Create New</a>
</p>
*@
<table class="table">
<thead>
<tr>
<th>Automezzo</th>
<th>Seriale</th>
<th>Data carico</th>
<th>Committente</th>
<th>Autista</th>
<th>Sede</th>
<th>Indirizzo sede</th>
@* <th>Num Riga</th>
<th>Ord riga</th> *@
<th>Merce</th>
<th>Note</th>
<th>Importo da ritirare</th>
@* <th>Consegna fatta</th> *@
<th>Seriale giro</th>
@* <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></th> *@
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CodAutomezzo) - @Html.DisplayFor(modelItem => item.DescAutomezzo)
</td>
<td>
@Html.DisplayFor(modelItem => item.Brserial)
</td>
<td>
@Html.DisplayFor(modelItem => item.DataCarico)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodCommittente) - @Html.DisplayFor(modelItem => item.Committente)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodAutista) - @Html.DisplayFor(modelItem => item.Autista)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodSede) - @Html.DisplayFor(modelItem => item.Sede)
</td>
<td>
@Html.DisplayFor(modelItem => item.IndirizzoSede)
</td>
<td>
@Html.DisplayFor(modelItem => item.Brmerce)
</td>
<td>
@Html.DisplayFor(modelItem => item.Brnote)
</td>
<td>
@Html.DisplayFor(modelItem => item.ImportoDaRitirare)
</td>
<td>
@Html.DisplayFor(modelItem => item.serialeGiro)
</td>
<td>
@Html.HiddenFor(modelItem => item.Cproword)
</td>
<td>
@Html.HiddenFor(modelItem => item.Cprownum)
</td>
<td>
@Html.HiddenFor(modelItem => item.ItemList)
</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>
}
</tbody>
</table>

View File

@ -8,7 +8,8 @@
<div class="row">
<div class="row">
<div class="col-md-8">
<form asp-action="Create">
<form asp-action="Create">
<div class="form-group" style="width: 40%;">
<h5><label asp-for="CodAutista" class="agy-client-quote"></label></h5>
@Html.DropDownListFor(x => x.CodAutista, (IEnumerable<SelectListItem>)ViewBag.Autisti, new { @class = "agy-form-field require" })

View File

@ -28,7 +28,6 @@
{
@* <div>@Html.TextBox("codAutista", null, new { placeholder = "Codice autista", @class = "agy-form-field require" })</div> *@
<div>@Html.DropDownList("codAutista", ViewBag.Autisti, null, new { @class = "agy-form-field require" })</div>
@* <div>@Html.DropDownListFor(x => x., (IEnumerable<SelectListItem>)ViewBag.Autisti, new { @class = "agy-form-field require" })</div> *@
<br />
<div>@Html.TextBox("data", null, new { type = "date", @class = "agy-form-field require" })</div>
<br />
@ -48,11 +47,12 @@
<th>Data</th>
@*<th>Cod. Autista</th>*@
<th>Autista</th>
<th>Automezzo</th>
<th>Bancali caricati</th>
<th>Bancali recuperati</th>
<th>Importo da recuperare</th>
<th>Importo recuperato</th>
<th>Data chiusura</th>
@* <th>Data chiusura</th> *@
@* <th hidden>
@Html.DisplayNameFor(model => model.SerialeGiro)
@ -88,13 +88,15 @@
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.DataGiro)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodAutista) - @Html.DisplayFor(modelItem => item.Autista)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodMezzo) - @Html.DisplayFor(modelItem => item.Automezzo)
</td>
@* <td>
@Html.DisplayFor(modelItem => item.Autista)
@ -113,17 +115,15 @@
@Html.DisplayFor(modelItem => item.ImportoRecuperato)
</td>
<td>
@Html.DisplayFor(modelItem => item.DataChiusura)
@Html.HiddenFor(modelItem => item.DataChiusura)
</td>
<td>
@Html.HiddenFor(modelItem => item.SerialeGiro)
</td>
<td>
<a href="@Url.Action("Index", "Destinazioni", new { id=item.SerialeGiro, codAutista=item.CodAutista, dataGiro=item.DataGiro, codMezzo=item.CodMezzo })" title="Destinazioni" class="links">Destinazioni</a>
<a href="@Url.Action("Chiudi", "GiriChiudi", new { id=item.SerialeGiro })" title="Chiudi" class="links">Chiudi</a>
<a href="@Url.Action("Elimina", "GiriElimina", new { id=item.SerialeGiro })" title="Elimina" class="links">Elimina</a>
</td>
</tr>
}