chiusura giro
This commit is contained in:
parent
ca8598236b
commit
e0ebf395e5
102
Controllers/GiriChiudiController.cs
Normal file
102
Controllers/GiriChiudiController.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SoftwayWeb.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SoftwayWeb.Controllers
|
||||||
|
{
|
||||||
|
public class GiriChiudiController : Controller
|
||||||
|
{
|
||||||
|
string apiUrl = string.Empty;
|
||||||
|
string urlBase = string.Empty;
|
||||||
|
string errMes = string.Empty;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
HttpClient client;
|
||||||
|
public GiriChiudiController(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
client = new HttpClient();
|
||||||
|
_configuration = configuration;
|
||||||
|
var key = _configuration["ApplicationInsights:rootUrlApi"];
|
||||||
|
apiUrl = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: GiriChiudiController
|
||||||
|
public ActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
public ActionResult Chiudi(string id)
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
GiriConsegnaView model = new GiriConsegnaView();
|
||||||
|
List<GiriConsegnaView> lst=new List<GiriConsegnaView>();
|
||||||
|
|
||||||
|
//https://api.poloinformatico.it:8000/api/Giri/listaGiri?aperto=true
|
||||||
|
|
||||||
|
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "Giri/listaGiri?aperto=true";
|
||||||
|
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;
|
||||||
|
lst = JsonConvert.DeserializeObject<List<GiriConsegnaView>>(data);
|
||||||
|
model = lst.Where(x => x.SerialeGiro.Equals(id)).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errMes = response.Content.ReadAsStringAsync().Result;
|
||||||
|
helper.SetStringValue("errMsg", errMes);
|
||||||
|
return RedirectToAction("Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult Chiudi(GiriConsegnaView model)
|
||||||
|
{
|
||||||
|
//https://api.poloinformatico.it:8000/api/Giri/closeGiro?serialeGiro=0000000002&bancaliRecuperati=11&importoRecuperato=100
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "Giri/closeGiro?serialeGiro=";
|
||||||
|
urlBase = urlBase + model.SerialeGiro;
|
||||||
|
urlBase = urlBase + "&bancaliRecuperati=";
|
||||||
|
urlBase = urlBase + model.BancaliRecuperati;
|
||||||
|
urlBase = urlBase + "&importoRecuperato=";
|
||||||
|
urlBase = urlBase + model.ImportoRecuperato;
|
||||||
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = baseAddress;
|
||||||
|
string data = JsonConvert.SerializeObject(model);
|
||||||
|
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||||
|
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return RedirectToAction("Index","Giri");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errMes = response.Content.ReadAsStringAsync().Result;
|
||||||
|
helper.SetStringValue("errMsg", errMes);
|
||||||
|
return RedirectToAction("Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
string e = helper.GetStringValue("errMsg");
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,5 +5,7 @@ namespace SoftwayWeb.Models
|
|||||||
public string? RequestId { get; set; }
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
|
||||||
|
public string? ErrMsg { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,13 +19,14 @@ namespace SoftwayWeb.Models
|
|||||||
[Display(Name = "Bancali caricati")]
|
[Display(Name = "Bancali caricati")]
|
||||||
public int? BancaliCaricati { get; set; }
|
public int? BancaliCaricati { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Bancali recuperati")]
|
|
||||||
|
[Display(Name = "Bancali recuperati"), Required(ErrorMessage = "Bancali recuperati obbligatori")]
|
||||||
public int? BancaliRecuperati { get; set; }
|
public int? BancaliRecuperati { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Importo da recuperare"), System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
[Display(Name = "Importo da recuperare"), System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
public decimal? ImportoDaRecuperare { get; set; }
|
public decimal? ImportoDaRecuperare { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Importo recuperato"),System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
[Display(Name = "Importo recuperato"),System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)"), Required(ErrorMessage = "Importo recuperato obbligatorio")]
|
||||||
public decimal? ImportoRecuperato { get; set; }
|
public decimal? ImportoRecuperato { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Data chiusura")]
|
[Display(Name = "Data chiusura")]
|
||||||
|
|||||||
52
Views/GiriChiudi/Chiudi.cshtml
Normal file
52
Views/GiriChiudi/Chiudi.cshtml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
@model SoftwayWeb.Models.GiriConsegnaView
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Area riservata";
|
||||||
|
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||||
|
}
|
||||||
|
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="row">
|
||||||
|
<form asp-action="Chiudi">
|
||||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<b>@Html.DisplayNameFor(model => model.SerialeGiro)</b> @Html.DisplayFor(model => model.SerialeGiro)
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<b>@Html.DisplayNameFor(model => model.Autista)</b> @Html.DisplayFor(model => model.CodAutista)-@Html.DisplayFor(model => model.Autista)
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<b>@Html.DisplayNameFor(model => model.DataGiro)</b> @Html.DisplayFor(model => model.DataGiro)
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<b>@Html.DisplayNameFor(model => model.BancaliCaricati)</b> @Html.DisplayFor(model => model.BancaliCaricati)
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<b>@Html.DisplayNameFor(model => model.ImportoDaRecuperare)</b> @Html.DisplayFor(model => model.ImportoDaRecuperare)
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<h5><label asp-for="BancaliRecuperati" class="agy-client-quote"></label></h5>
|
||||||
|
<input asp-for="BancaliRecuperati" class="agy-form-field require" placeholder="Bancali recuperati" />
|
||||||
|
<span asp-validation-for="BancaliRecuperati" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<h5><label asp-for="ImportoRecuperato" class="agy-client-quote"></label></h5>
|
||||||
|
<input asp-for="ImportoRecuperato" class="agy-form-field require" placeholder="Importo recuperato" />
|
||||||
|
<span asp-validation-for="ImportoRecuperato" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="submit" value="Salva" class="agy-btn submitForm" />
|
||||||
|
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
|
||||||
|
</div>
|
||||||
|
@Html.HiddenFor(x => x.SerialeGiro)
|
||||||
|
@Html.HiddenFor(x => x.CodAutista)
|
||||||
|
@Html.HiddenFor(x => x.Autista)
|
||||||
|
@Html.HiddenFor(x => x.DataGiro)
|
||||||
|
@Html.HiddenFor(x => x.BancaliCaricati)
|
||||||
|
@Html.HiddenFor(x => x.ImportoDaRecuperare)
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue
Block a user