Michele: Controller + metodi + view per elimana
This commit is contained in:
parent
8fd04f1934
commit
782eef1d71
@ -60,6 +60,15 @@ namespace SoftwayWeb.Controllers
|
|||||||
{
|
{
|
||||||
modelList = modelList.Where(x => x.DataGiro.GetValueOrDefault().Date == data.Date).ToList();
|
modelList = modelList.Where(x => x.DataGiro.GetValueOrDefault().Date == data.Date).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (aperto)
|
||||||
|
//{
|
||||||
|
// modelList = modelList.Where(x => x.DataChiusura == null).ToList();
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// modelList = modelList.Where(x => x.DataChiusura != null).ToList();
|
||||||
|
//}
|
||||||
//var shortList = modelList.ToPagedList();
|
//var shortList = modelList.ToPagedList();
|
||||||
return View(modelList);
|
return View(modelList);
|
||||||
}
|
}
|
||||||
|
|||||||
105
Controllers/GiriEliminaController.cs
Normal file
105
Controllers/GiriEliminaController.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SoftwayWeb.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SoftwayWeb.Controllers
|
||||||
|
{
|
||||||
|
public class GiriEliminaController : Controller
|
||||||
|
{
|
||||||
|
string apiUrl = string.Empty;
|
||||||
|
string urlBase = string.Empty;
|
||||||
|
string errMes = string.Empty;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
HttpClient client;
|
||||||
|
|
||||||
|
public GiriEliminaController(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
client = new HttpClient();
|
||||||
|
_configuration = configuration;
|
||||||
|
var key = _configuration["ApplicationInsights:rootUrlApi"];
|
||||||
|
apiUrl = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return RedirectToAction("index", "Giri");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Elimina(string id)
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
GiriConsegnaView model = new GiriConsegnaView();
|
||||||
|
List<GiriConsegnaView> modelList = new List<GiriConsegnaView>();
|
||||||
|
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
//urlBase = apiUrl + "Giri/delGiro";
|
||||||
|
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;
|
||||||
|
modelList = JsonConvert.DeserializeObject<List<GiriConsegnaView>>(data);
|
||||||
|
model = modelList.Where(x => x.SerialeGiro.Equals(id)).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errMes = response.Content.ReadAsStringAsync().Result;
|
||||||
|
helper.SetStringValue("errMsg", errMes);
|
||||||
|
return RedirectToAction("Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost, ActionName("Elimina")]
|
||||||
|
public IActionResult Elimina(GiriConsegnaView model)
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "Giri/delGiro?serialeGiro=";
|
||||||
|
urlBase = urlBase + model.SerialeGiro.TrimEnd();
|
||||||
|
urlBase = urlBase + "&autista=";
|
||||||
|
urlBase = urlBase + model.CodAutista.TrimEnd();
|
||||||
|
urlBase = urlBase + "&data=";
|
||||||
|
urlBase = urlBase + model.DataGiro;
|
||||||
|
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Views/GiriElimina/Elimina.cshtml
Normal file
52
Views/GiriElimina/Elimina.cshtml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
@model SoftwayWeb.Models.GiriConsegnaView
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Elimina";
|
||||||
|
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="Elimina">
|
||||||
|
<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="Elimina" 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