inserimento giro
This commit is contained in:
parent
c43e79df03
commit
fb41a08dee
@ -1,6 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SoftwayWeb.Models;
|
using SoftwayWeb.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.Intrinsics.Arm;
|
||||||
|
using System.Text;
|
||||||
using X.PagedList;
|
using X.PagedList;
|
||||||
|
|
||||||
namespace SoftwayWeb.Controllers
|
namespace SoftwayWeb.Controllers
|
||||||
@ -66,5 +70,81 @@ namespace SoftwayWeb.Controllers
|
|||||||
return RedirectToAction("Error");
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult Create()
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
ViewBag.Autisti = getAutisti();
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Create(GiriConsegnaView model)
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
ViewBag.Autisti = getAutisti();
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "Giri/addGiro2";
|
||||||
|
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
private List<SelectListItem> getAutisti()
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "Giri/listaAutisti";
|
||||||
|
|
||||||
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = baseAddress;
|
||||||
|
List<SelectListItem> selectItems = new List<SelectListItem>();
|
||||||
|
List<Personale> modelList = new List<Personale>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string data = response.Content.ReadAsStringAsync().Result;
|
||||||
|
modelList = JsonConvert.DeserializeObject<List<Personale>>(data);
|
||||||
|
|
||||||
|
//per gestire primo elemento tendina (deve essere vuoto)
|
||||||
|
SelectListItem listItemFirt = new SelectListItem();
|
||||||
|
|
||||||
|
listItemFirt.Value = string.Empty;
|
||||||
|
listItemFirt.Text = " - Autista";
|
||||||
|
selectItems.Add(listItemFirt);
|
||||||
|
|
||||||
|
foreach (var role in modelList)
|
||||||
|
{
|
||||||
|
SelectListItem listItem = new SelectListItem();
|
||||||
|
string s = role.Catcodice + " - " + role.Catnome;
|
||||||
|
listItem.Value = role.Catcodice;
|
||||||
|
listItem.Text = s;
|
||||||
|
selectItems.Add(listItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
Models/Personale.cs
Normal file
13
Models/Personale.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace SoftwayWeb.Models
|
||||||
|
{
|
||||||
|
public class Personale
|
||||||
|
{
|
||||||
|
public string? Catcodice { get; set; } = null;
|
||||||
|
public string? Catnome { get; set; } = null;
|
||||||
|
public string? Cattelefono { get; set; } = null;
|
||||||
|
public string? Catcellulare { get; set; } = null;
|
||||||
|
public string? Tcuser { get; set; } = null;
|
||||||
|
public string? Tcpwd { get; set; } = null;
|
||||||
|
public string? Tcruolo { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
58
Views/Giri/Create.cshtml
Normal file
58
Views/Giri/Create.cshtml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
@model SoftwayWeb.Models.GiriConsegnaView
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Create";
|
||||||
|
Layout = "~/Views/Shared/_LayoutAreaRis.cshtml";
|
||||||
|
}
|
||||||
|
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<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" })
|
||||||
|
<span asp-validation-for="CodAutista" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
<div class="form-group" style="width: 40%;">
|
||||||
|
<h5><label asp-for="DataGiro" class="agy-client-quote"></label></h5>
|
||||||
|
@Html.TextBox("DataGiro", null, new { type = "date", @class = "agy-form-field require" })
|
||||||
|
<span asp-validation-for="DataGiro" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
<div class="form-group" style="width: 40%;">
|
||||||
|
<h5><label asp-for="ImportoDaRecuperare" class="agy-client-quote"></label></h5>
|
||||||
|
<input asp-for="ImportoDaRecuperare" class="agy-form-field require" placeholder="Importo Da Recuperare" />
|
||||||
|
<span asp-validation-for="ImportoDaRecuperare" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
<div class="form-group" style="width: 40%;">
|
||||||
|
<h5><label asp-for="BancaliCaricati" class="agy-client-quote"></label></h5>
|
||||||
|
<input asp-for="BancaliCaricati" class="agy-form-field require" placeholder="Bancali Caricati" />
|
||||||
|
<span asp-validation-for="BancaliCaricati" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
|
<div class="form-group" style="width: 40%;">
|
||||||
|
<input type="submit" value="Salva" class="agy-btn submitForm" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@Html.HiddenFor(x => x.SerialeGiro)
|
||||||
|
@Html.HiddenFor(x => x.Autista)
|
||||||
|
@Html.HiddenFor(x => x.BancaliRecuperati)
|
||||||
|
@Html.HiddenFor(x => x.ImportoRecuperato)
|
||||||
|
@Html.HiddenFor(x => x.DataChiusura)
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@{
|
||||||
|
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -114,8 +114,7 @@
|
|||||||
@Html.HiddenFor(modelItem => item.SerialeGiro)
|
@Html.HiddenFor(modelItem => item.SerialeGiro)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@* @Html.ActionLink("Chiudi", "Chiudi", new { id=item.SerialeGiro }) |
|
|
||||||
@Html.ActionLink("Elimina", "Elimina", new { id=item.SerialeGiro })*@
|
|
||||||
|
|
||||||
<a href="@Url.Action("Chiudi", "GiriChiudi", new { id=item.SerialeGiro })" title="Chiudi" class="links">Chiudi</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>
|
<a href="@Url.Action("Elimina", "GiriElimina", new { id=item.SerialeGiro })" title="Elimina" class="links">Elimina</a>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user