Michele: Lista giri
This commit is contained in:
parent
583e123ef3
commit
1219ed236c
65
Controllers/GiriController.cs
Normal file
65
Controllers/GiriController.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SoftwayWeb.Models;
|
||||||
|
using X.PagedList;
|
||||||
|
|
||||||
|
namespace SoftwayWeb.Controllers
|
||||||
|
{
|
||||||
|
public class GiriController : 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 GiriController(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_configuration = configuration;
|
||||||
|
client = new HttpClient();
|
||||||
|
var key = _configuration["ApplicationInsights:rootUrlApi"];
|
||||||
|
apiUrl = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index(string? codAutista, DateTime? data, bool aperto = true)
|
||||||
|
{
|
||||||
|
helper = new SessionHelper(this);
|
||||||
|
token = helper.GetStringValue("tok");
|
||||||
|
string url = apiUrl + "Giri/listaGiri";
|
||||||
|
urlBase = url + "?token=" + token;
|
||||||
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = baseAddress;
|
||||||
|
|
||||||
|
List<GiriConsegnaView> modelList = new List<GiriConsegnaView>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string dato = response.Content.ReadAsStringAsync().Result;
|
||||||
|
modelList = JsonConvert.DeserializeObject<List<GiriConsegnaView>>(dato);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(codAutista))
|
||||||
|
{
|
||||||
|
modelList = modelList.Where(x => x.CodAutista.Contains(codAutista)).ToList();
|
||||||
|
|
||||||
|
ViewData["CurrentFilter"] = codAutista;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ViewData["CurrentFilter"] = null;
|
||||||
|
}
|
||||||
|
//var shortList = modelList.ToPagedList();
|
||||||
|
return View(modelList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errMes = response.Content.ReadAsStringAsync().Result;
|
||||||
|
helper.SetStringValue("errMsg", errMes);
|
||||||
|
return RedirectToAction("Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -36,14 +36,14 @@ namespace SoftwayWeb.Controllers
|
|||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
helper = new SessionHelper(this);
|
SessionHelper helper = new SessionHelper(this);
|
||||||
string url = apiUrl + "Login/loginMagazzino";
|
string url = apiUrl + "Login/loginMagazzino";
|
||||||
Uri baseAddress = new Uri(url);
|
Uri baseAddress = new Uri(url);
|
||||||
client.BaseAddress = baseAddress;
|
client.BaseAddress = baseAddress;
|
||||||
//ViewBag.Error = string.Empty;
|
//ViewBag.Error = string.Empty;
|
||||||
//ViewBag.Admin = string.Empty;
|
//ViewBag.Admin = string.Empty;
|
||||||
|
|
||||||
Login_Out loginOutput = new Login_Out();
|
Login_Out loginOut = new Login_Out();
|
||||||
string data = JsonConvert.SerializeObject(model);
|
string data = JsonConvert.SerializeObject(model);
|
||||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||||
@ -51,14 +51,17 @@ namespace SoftwayWeb.Controllers
|
|||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
string risultato = response.Content.ReadAsStringAsync().Result;
|
string risultato = response.Content.ReadAsStringAsync().Result;
|
||||||
loginOutput = JsonConvert.DeserializeObject<Login_Out>(risultato);
|
loginOut = JsonConvert.DeserializeObject<Login_Out>(risultato);
|
||||||
|
|
||||||
return RedirectToAction("Index", "Portale");
|
helper.SetStringValue("tok", loginOut.Tok);
|
||||||
|
helper.SetStringValue("apiUrl", apiUrl);
|
||||||
|
|
||||||
|
return RedirectToAction("Index", "Portale");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
errMes = response.Content.ReadAsStringAsync().Result;
|
errMes = response.Content.ReadAsStringAsync().Result;
|
||||||
loginOutput = JsonConvert.DeserializeObject<Login_Out>(errMes);
|
loginOut = JsonConvert.DeserializeObject<Login_Out>(errMes);
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
//return View(model);
|
//return View(model);
|
||||||
|
|||||||
@ -1,12 +1,39 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NuGet.Common;
|
||||||
|
|
||||||
namespace SoftwayWeb.Controllers
|
namespace SoftwayWeb.Controllers
|
||||||
{
|
{
|
||||||
public class PortaleController : Controller
|
public class PortaleController : Controller
|
||||||
{
|
{
|
||||||
|
string apiUrl = string.Empty;
|
||||||
|
string token = string.Empty;
|
||||||
|
string errMes = string.Empty;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
HttpClient client;
|
||||||
|
SessionHelper helper;
|
||||||
|
|
||||||
|
public PortaleController(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_configuration = configuration;
|
||||||
|
client = new HttpClient();
|
||||||
|
var key = _configuration["ApplicationInsights:rootUrlApi"];
|
||||||
|
apiUrl = key;
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
helper = new SessionHelper(this);
|
||||||
|
token = helper.GetStringValue("tok");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(token))
|
||||||
|
{
|
||||||
|
return RedirectToAction("Login", "Login");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
Models/GiriConsegnaView.cs
Normal file
34
Models/GiriConsegnaView.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SoftwayWeb.Models
|
||||||
|
{
|
||||||
|
public class GiriConsegnaView
|
||||||
|
{
|
||||||
|
[Display(Name = "Seriale Giro")]
|
||||||
|
public string? SerialeGiro { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Data")]
|
||||||
|
public DateTime? DataGiro { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Cod. Autista")]
|
||||||
|
public string? CodAutista { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Autista")]
|
||||||
|
public string? Autista { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Bancali caricati")]
|
||||||
|
public int? BancaliCaricati { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Bancali recuperati")]
|
||||||
|
public int? BancaliRecuperati { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Importo da recuperare"), System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
|
public decimal? ImportoDaRecuperare { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Importo recuperato"),System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
|
public decimal? ImportoRecuperato { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Data chiusura")]
|
||||||
|
public DateTime? DataChiusura { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Program.cs
52
Program.cs
@ -2,7 +2,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
builder.Services.AddSession();
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@ -20,8 +20,56 @@ app.UseRouting();
|
|||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseSession();
|
||||||
|
|
||||||
app.MapControllerRoute(
|
app.MapControllerRoute(
|
||||||
name: "default",
|
name: "default",
|
||||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
//app.UseSession();
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////
|
||||||
|
//var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
//// Add services to the container.
|
||||||
|
//builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
//builder.Services.AddDistributedMemoryCache();
|
||||||
|
|
||||||
|
//builder.Services.AddSession(options =>
|
||||||
|
//{
|
||||||
|
|
||||||
|
// options.Cookie.HttpOnly = true;
|
||||||
|
// options.Cookie.IsEssential = true;
|
||||||
|
//});
|
||||||
|
//builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
|
//var app = builder.Build();
|
||||||
|
|
||||||
|
//// Configure the HTTP request pipeline.
|
||||||
|
//if (!app.Environment.IsDevelopment())
|
||||||
|
//{
|
||||||
|
// app.UseExceptionHandler("/Home/Error");
|
||||||
|
// // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
|
// app.UseHsts();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//app.UseHttpsRedirection();
|
||||||
|
//app.UseStaticFiles();
|
||||||
|
|
||||||
|
//app.UseRouting();
|
||||||
|
|
||||||
|
//app.UseAuthorization();
|
||||||
|
|
||||||
|
////app.MapControllerRoute(
|
||||||
|
//// name: "default",
|
||||||
|
//// pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
//app.MapControllerRoute(
|
||||||
|
// name: "default",
|
||||||
|
// pattern: "{controller=Portale}/{action=Index}");
|
||||||
|
//app.UseSession();
|
||||||
|
//app.Run();
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
|
||||||
|
<PackageReference Include="X.PagedList.Mvc.Core" Version="9.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
115
Views/Giri/Index.cshtml
Normal file
115
Views/Giri/Index.cshtml
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
@model IEnumerable<SoftwayWeb.Models.GiriConsegnaView>
|
||||||
|
@* @model IPagedList<SoftwayWeb.Models.GiriConsegnaView> *@
|
||||||
|
@using X.PagedList;
|
||||||
|
@using X.PagedList.Mvc.Core;
|
||||||
|
@using X.PagedList;
|
||||||
|
|
||||||
|
|
||||||
|
@* @using X.PagedList.Web.Common; *@
|
||||||
|
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Index";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1>Giri di consegna</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a asp-action="Create">Aggiungi nuovo giro di consegna</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@using (Html.BeginForm(@* "Index", "Giri" *@))
|
||||||
|
{
|
||||||
|
@* <div style="float:left;width:40%;padding:0 20px;">@Html.TextBox("codAuti", null, new { placeholder = "Codice autista", @class = "agy-form-field require" })</div>
|
||||||
|
<div style="float:left;width:40%;padding:0 20px;">@Html.TextBox("dataCons", null, new { placeholder = "Data consegna", @class = "agy-form-field require" })</div>
|
||||||
|
<div style="float:left;width:57%;"><input type="submit" value="Cerca" class="agy-btn submitForm" /></div> *@
|
||||||
|
<div>@Html.TextBox("codAutista", null, new { placeholder = "Codice autista", @class = "agy-form-field require" })</div>
|
||||||
|
<br />
|
||||||
|
<div>@Html.TextBox("data", null, new { type = "date", @class = "agy-form-field require" })</div>
|
||||||
|
<br />
|
||||||
|
<div style="float:left;width:57%;"><input type="submit" value="Cerca" class="agy-btn submitForm" /></div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Seriale giro</th>
|
||||||
|
<th>Data</th>
|
||||||
|
<th>Cod. Autista</th>
|
||||||
|
<th>Autista</th>
|
||||||
|
<th>Bancali caricati</th>
|
||||||
|
<th>Bancali recuperati</th>
|
||||||
|
<th>Importo da recuperare</th>
|
||||||
|
<th>Importo recuperato</th>
|
||||||
|
<th>Data chiusura</th>
|
||||||
|
|
||||||
|
@* <th hidden>
|
||||||
|
@Html.DisplayNameFor(model => model.SerialeGiro)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.DataGiro)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.CodAutista)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.Autista)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.BancaliCaricati)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.BancaliRecuperati)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.ImportoDaRecuperare)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.ImportoRecuperato)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.DataChiusura)
|
||||||
|
</th>
|
||||||
|
<th></th> *@
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.SerialeGiro)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DataGiro)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.CodAutista)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Autista)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.BancaliCaricati)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.BancaliRecuperati)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ImportoDaRecuperare)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ImportoRecuperato)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DataChiusura)
|
||||||
|
</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>
|
||||||
@ -3,6 +3,25 @@
|
|||||||
|
|
||||||
*@
|
*@
|
||||||
@{
|
@{
|
||||||
|
ViewData["Title"] = "Area riservata";
|
||||||
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||||
}
|
}
|
||||||
Area riservata dopo login
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"] - SoftwayWeb</title>
|
||||||
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/SoftwayWeb.styles.css" asp-append-version="true" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
@* <div class="col-lg-12 col-md-12 col-sm-12 col-12">
|
||||||
|
<input type="submit" value="Giri" class="agy-btn submitForm" />
|
||||||
|
<div class="response"></div>
|
||||||
|
</div> *@
|
||||||
|
|
||||||
|
<a href="@Url.Action("Index", "Giri")" title="Giri Consegna" class="links">Giri Consegna</a>
|
||||||
|
</body>
|
||||||
Loading…
Reference in New Issue
Block a user