From 67471ee2ac817057b4741f051bb563ccb2eedc15 Mon Sep 17 00:00:00 2001 From: michele Date: Thu, 27 Jun 2024 17:22:58 +0200 Subject: [PATCH] Michele: destinazioni - controller, index, model + GiriConsegna - aggiunta mezzo e codice mezzo su model --- Controllers/DestinazioniController.cs | 58 ++++++++++ Models/Destinazioni_Out.cs | 68 ++++++++++++ Models/GiriConsegnaView.cs | 6 ++ Views/Destinazioni/Index.cshtml | 148 ++++++++++++++++++++++++++ Views/Giri/Create.cshtml | 3 +- Views/Giri/Index.cshtml | 14 +-- 6 files changed, 289 insertions(+), 8 deletions(-) create mode 100644 Controllers/DestinazioniController.cs create mode 100644 Models/Destinazioni_Out.cs create mode 100644 Views/Destinazioni/Index.cshtml diff --git a/Controllers/DestinazioniController.cs b/Controllers/DestinazioniController.cs new file mode 100644 index 0000000..6a344f9 --- /dev/null +++ b/Controllers/DestinazioniController.cs @@ -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 modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string dato = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(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); + } + } +} diff --git a/Models/Destinazioni_Out.cs b/Models/Destinazioni_Out.cs new file mode 100644 index 0000000..3748f4a --- /dev/null +++ b/Models/Destinazioni_Out.cs @@ -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; } + + + } + } +} diff --git a/Models/GiriConsegnaView.cs b/Models/GiriConsegnaView.cs index 5adf0c0..00ba24a 100644 --- a/Models/GiriConsegnaView.cs +++ b/Models/GiriConsegnaView.cs @@ -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; } } } diff --git a/Views/Destinazioni/Index.cshtml b/Views/Destinazioni/Index.cshtml new file mode 100644 index 0000000..a385066 --- /dev/null +++ b/Views/Destinazioni/Index.cshtml @@ -0,0 +1,148 @@ +@model IEnumerable +@* @model SoftwayWeb.Models.Destinazioni_Out *@ +@using X.PagedList; +@using X.PagedList.Mvc.Core; +@using X.PagedList; +@{ + ViewData["Title"] = "Index"; +} + +

Lista destinazioni

+ +@*

+ Create New +

+ *@ + + + + + + + + + + + + @* + *@ + + + + @* *@ + + + + @* + + + + + + + + + + + + + + + + + + *@ + + + +@foreach (var item in Model) { + + + + + + + + + + + + + + + + + + @* *@ + + } + +
AutomezzoSerialeData caricoCommittenteAutistaSedeIndirizzo sedeNum RigaOrd rigaMerceNoteImporto da ritirareConsegna fattaSeriale giro + @Html.DisplayNameFor(model => model.CodAutomezzo) + + @Html.DisplayNameFor(model => model.DescAutomezzo) + + @Html.DisplayNameFor(model => model.Brserial) + + @Html.DisplayNameFor(model => model.DataCarico) + + @Html.DisplayNameFor(model => model.CodCommittente) + + @Html.DisplayNameFor(model => model.Committente) + + @Html.DisplayNameFor(model => model.CodAutista) + + @Html.DisplayNameFor(model => model.Autista) + + @Html.DisplayNameFor(model => model.CodSede) + + @Html.DisplayNameFor(model => model.Sede) + + @Html.DisplayNameFor(model => model.IndirizzoSede) + + @Html.DisplayNameFor(model => model.Cproword) + + @Html.DisplayNameFor(model => model.Cprownum) + + @Html.DisplayNameFor(model => model.Brmerce) + + @Html.DisplayNameFor(model => model.Brnote) + + @Html.DisplayNameFor(model => model.ImportoDaRitirare) + + @Html.DisplayNameFor(model => model.ItemList) + + @Html.DisplayNameFor(model => model.serialeGiro) +
+ @Html.DisplayFor(modelItem => item.CodAutomezzo) - @Html.DisplayFor(modelItem => item.DescAutomezzo) + + @Html.DisplayFor(modelItem => item.Brserial) + + @Html.DisplayFor(modelItem => item.DataCarico) + + @Html.DisplayFor(modelItem => item.CodCommittente) - @Html.DisplayFor(modelItem => item.Committente) + + @Html.DisplayFor(modelItem => item.CodAutista) - @Html.DisplayFor(modelItem => item.Autista) + + @Html.DisplayFor(modelItem => item.CodSede) - @Html.DisplayFor(modelItem => item.Sede) + + @Html.DisplayFor(modelItem => item.IndirizzoSede) + + @Html.DisplayFor(modelItem => item.Brmerce) + + @Html.DisplayFor(modelItem => item.Brnote) + + @Html.DisplayFor(modelItem => item.ImportoDaRitirare) + + @Html.DisplayFor(modelItem => item.serialeGiro) + + @Html.HiddenFor(modelItem => item.Cproword) + + @Html.HiddenFor(modelItem => item.Cprownum) + + @Html.HiddenFor(modelItem => item.ItemList) + + @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) +
diff --git a/Views/Giri/Create.cshtml b/Views/Giri/Create.cshtml index a219e77..3f73775 100644 --- a/Views/Giri/Create.cshtml +++ b/Views/Giri/Create.cshtml @@ -8,7 +8,8 @@
-
+ +
@Html.DropDownListFor(x => x.CodAutista, (IEnumerable)ViewBag.Autisti, new { @class = "agy-form-field require" }) diff --git a/Views/Giri/Index.cshtml b/Views/Giri/Index.cshtml index a064496..e46bdd9 100644 --- a/Views/Giri/Index.cshtml +++ b/Views/Giri/Index.cshtml @@ -28,7 +28,6 @@ { @*
@Html.TextBox("codAutista", null, new { placeholder = "Codice autista", @class = "agy-form-field require" })
*@
@Html.DropDownList("codAutista", ViewBag.Autisti, null, new { @class = "agy-form-field require" })
- @*
@Html.DropDownListFor(x => x., (IEnumerable)ViewBag.Autisti, new { @class = "agy-form-field require" })
*@
@Html.TextBox("data", null, new { type = "date", @class = "agy-form-field require" })

@@ -48,11 +47,12 @@ Data @*Cod. Autista*@ Autista + Automezzo Bancali caricati Bancali recuperati Importo da recuperare Importo recuperato - Data chiusura + @* Data chiusura *@ @* @Html.DisplayNameFor(model => model.SerialeGiro) @@ -88,13 +88,15 @@ @foreach (var item in Model) { - @Html.DisplayFor(modelItem => item.DataGiro) @Html.DisplayFor(modelItem => item.CodAutista) - @Html.DisplayFor(modelItem => item.Autista) + + @Html.DisplayFor(modelItem => item.CodMezzo) - @Html.DisplayFor(modelItem => item.Automezzo) + @* @Html.DisplayFor(modelItem => item.Autista) @@ -113,17 +115,15 @@ @Html.DisplayFor(modelItem => item.ImportoRecuperato) - @Html.DisplayFor(modelItem => item.DataChiusura) + @Html.HiddenFor(modelItem => item.DataChiusura) @Html.HiddenFor(modelItem => item.SerialeGiro) - - + Destinazioni Chiudi Elimina - }