Anagrafiche 2

This commit is contained in:
Marco Audiffredi 2023-10-05 17:23:49 +02:00
parent 40c14060e7
commit 7ead066acc
6 changed files with 156 additions and 123 deletions

View File

@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NuGet.Common;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Intrinsics.Arm;
using System.Text;
using VirtualTask.Models;
@ -14,13 +16,13 @@ namespace VirtualTask.Controllers
string apiUrl = string.Empty;
string urlBase=string.Empty;
string token=string.Empty;
//Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/anagraficheList?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
//Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/anagraficheList?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
string tenant = string.Empty;
string errMes = string.Empty;
HttpClient client;
public AnagController()
{
{
client = new HttpClient();
}
#region INDEX
@ -36,7 +38,6 @@ namespace VirtualTask.Controllers
urlBase = apiUrl+"anagraficheList";
urlBase = urlBase + "?token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
List<Anag> modelList = new List<Anag>();
@ -46,31 +47,38 @@ namespace VirtualTask.Controllers
{
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Anag>>(data);
}
if (!string.IsNullOrEmpty(searchString))
{
modelList = modelList.Where(s => s.andescri.ToUpper().Contains(searchString.ToUpper())).ToList();
if (!string.IsNullOrEmpty(searchString))
{
modelList = modelList.Where(s => s.andescri.ToUpper().Contains(searchString.ToUpper())).ToList();
ViewData["CurrentFilter"] = searchString;
ViewData["CurrentFilter"] = searchString;
}
else
{
ViewData["CurrentFilter"] = null;
}
if (page != null && page < 1)
{
page = 1;
}
var pageSize = 10;
var shortLinks = modelList
.OrderByDescending(s => s.ancodice)
.ToPagedList(page ?? 1, pageSize);
return View(shortLinks);
}
else
{
ViewData["CurrentFilter"] = null;
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
if (page != null && page < 1)
{
page = 1;
}
var pageSize = 10;
var shortLinks = modelList
.OrderByDescending(s => s.ancodice)
.ToPagedList(page ?? 1, pageSize);
return View(shortLinks);
}
#endregion INDEX
@ -88,7 +96,8 @@ namespace VirtualTask.Controllers
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
tenant = helper.GetStringValue("tenant");
model.ancodazi=tenant;
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "anagrafiche/add";
urlBase = urlBase + "?token=" + token;
@ -103,8 +112,13 @@ namespace VirtualTask.Controllers
{
return RedirectToAction("Index");
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View();
}
#endregion CREATE
@ -136,6 +150,12 @@ namespace VirtualTask.Controllers
modelList = JsonConvert.DeserializeObject<List<Anag>>(data);
anag = modelList.Where(x => x.ancodice.Equals(id)).First();
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View(anag);
}
@ -168,7 +188,13 @@ namespace VirtualTask.Controllers
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Anag>>(data);
anag = modelList.Where(x => x.ancodice.Equals(id)).First();
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View(anag);
@ -180,7 +206,8 @@ namespace VirtualTask.Controllers
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
tenant = helper.GetStringValue("tenant");
model.ancodazi = tenant;
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "anagrafiche/mod";
urlBase = urlBase + "?token=" + token;
@ -198,8 +225,13 @@ namespace VirtualTask.Controllers
{
return RedirectToAction("Index");
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View(model);
}
#endregion EDIT
@ -238,20 +270,22 @@ namespace VirtualTask.Controllers
//DA MODIFICARE PERCHE' NON E' UNA DELETE MA UN UPDATE DELLA DATA OBSOLESCENZA
[HttpPost, ActionName("DeleteConfirmed")]
public IActionResult DeleteConfirmed(string id)
public IActionResult DeleteConfirmed(Anag model)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
tenant = helper.GetStringValue("tenant");
model.ancodazi = tenant;
model.andtobso=DateTime.Now;
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "anagrafiche/del?" + "codice=" + id + "&";
urlBase = urlBase + "token=" + token;
urlBase = apiUrl + "anagrafiche/del";
urlBase = urlBase + "?token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
string data = JsonConvert.SerializeObject(id);
string data = JsonConvert.SerializeObject(model);
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
@ -261,10 +295,23 @@ namespace VirtualTask.Controllers
{
return RedirectToAction("Index");
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View();
}
#endregion DELETE
[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 });
}
}
}

View File

@ -6,13 +6,17 @@ namespace VirtualTask.Models
public class Anag
{
[Display(Name = "TIPO")]
/// <summary>tipo </summary>
/// <summary>tipo (chiave)</summary>
public string? antipcon { get; set; }
[Display(Name = "CODICE")]
/// <summary>codice</summary>
/// <summary>codice (chiave)</summary>
public string? ancodice { get; set; }
[Display(Name = "AZIENDA")]
/// <summary>aziewnda (chiave)</summary>
public string? ancodazi { get; set; }
[Display(Name = "EMAIL")]
/// <summary>email</summary>
public string? an_email { get; set; }

View File

@ -12,21 +12,21 @@
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="antipcon" class="control-label"></label>
<input asp-for="antipcon" class="form-control" />
<span asp-validation-for="antipcon" class="text-danger"></span>
</div>
<input type="hidden" id="antipcon" value="C" name="antipcon" />
@Html.HiddenFor(x => x.andtobso)
@Html.HiddenFor(x => x.annumlis)
<div class="form-group">
<label asp-for="ancodice" class="control-label"></label>
<input asp-for="ancodice" class="form-control" />
<span asp-validation-for="ancodice" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="an_email" class="control-label"></label>
<input asp-for="an_email" class="form-control" />
<span asp-validation-for="an_email" class="text-danger"></span>
<label asp-for="andescri" class="control-label"></label>
<input asp-for="andescri" class="form-control" />
<span asp-validation-for="andescri" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ancodfis" class="control-label"></label>
<input asp-for="ancodfis" class="form-control" />
@ -52,26 +52,18 @@
<input asp-for="annumcel" class="form-control" />
<span asp-validation-for="annumcel" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="an_email" class="control-label"></label>
<input asp-for="an_email" class="form-control" />
<span asp-validation-for="an_email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="an_empec" class="control-label"></label>
<input asp-for="an_empec" class="form-control" />
<span asp-validation-for="an_empec" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="andescri" class="control-label"></label>
<input asp-for="andescri" class="form-control" />
<span asp-validation-for="andescri" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="annumlis" class="control-label"></label>
<input asp-for="annumlis" class="form-control" />
<span asp-validation-for="annumlis" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="andtobso" class="control-label"></label>
<input asp-for="andtobso" class="form-control" />
<span asp-validation-for="andtobso" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>

View File

@ -16,51 +16,61 @@
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.antipcon)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.ancodice)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.ancodice)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.an_email)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.an_email)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.ancodfis)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.ancodfis)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.anpariva)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.anpariva)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.anindiri)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.anindiri)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.antelefo)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.antelefo)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.annumcel)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.annumcel)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.an_empec)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.an_empec)
@ -70,24 +80,25 @@
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.andescri)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.annumlis)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.annumlis)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.andtobso)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.andtobso)
</dd>
</dl>
<form asp-action="DeleteConfirmed">
@Html.HiddenFor(x => x.annumlis)
@Html.HiddenFor(x => x.andescri)
@Html.HiddenFor(x => x.an_empec)
@Html.HiddenFor(x => x.annumcel)
@Html.HiddenFor(x => x.antelefo)
@Html.HiddenFor(x => x.anindiri)
@Html.HiddenFor(x => x.anpariva)
@Html.HiddenFor(x => x.ancodfis)
@Html.HiddenFor(x => x.an_email)
@Html.HiddenFor(x => x.ancodice)
@Html.HiddenFor(x => x.antipcon)
<input type="submit" value="Delete" class="btn btn-danger" /> |
<input type="hidden" id="id" value=@Html.DisplayFor(model => model.ancodice) name="id" />
<a asp-action="Index">Back to List</a>
</form>
</div>

View File

@ -10,24 +10,20 @@
<h4>Anag</h4>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.antipcon)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.antipcon)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.ancodice)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.ancodice)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.an_email)
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.andescri)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.an_email)
<dd class="col-sm-10">
@Html.DisplayFor(model => model.andescri)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.ancodfis)
</dt>
@ -58,30 +54,20 @@
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.annumcel)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.an_email)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.an_email)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.an_empec)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.an_empec)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.andescri)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.andescri)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.annumlis)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.annumlis)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.andtobso)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.andtobso)
</dd>
</dl>
</div>
<div>

View File

@ -12,21 +12,21 @@
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="antipcon" class="control-label"></label>
<input asp-for="antipcon" class="form-control" />
<span asp-validation-for="antipcon" class="text-danger"></span>
</div>
@Html.HiddenFor(x => x.antipcon)
@Html.HiddenFor(x => x.andtobso)
@Html.HiddenFor(x => x.annumlis)
<div class="form-group">
<label asp-for="ancodice" class="control-label"></label>
<input asp-for="ancodice" class="form-control" />
<span asp-validation-for="ancodice" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="an_email" class="control-label"></label>
<input asp-for="an_email" class="form-control" />
<span asp-validation-for="an_email" class="text-danger"></span>
<label asp-for="andescri" class="control-label"></label>
<input asp-for="andescri" class="form-control" />
<span asp-validation-for="andescri" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ancodfis" class="control-label"></label>
<input asp-for="ancodfis" class="form-control" />
@ -52,26 +52,19 @@
<input asp-for="annumcel" class="form-control" />
<span asp-validation-for="annumcel" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="an_email" class="control-label"></label>
<input asp-for="an_email" class="form-control" />
<span asp-validation-for="an_email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="an_empec" class="control-label"></label>
<input asp-for="an_empec" class="form-control" />
<span asp-validation-for="an_empec" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="andescri" class="control-label"></label>
<input asp-for="andescri" class="form-control" />
<span asp-validation-for="andescri" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="annumlis" class="control-label"></label>
<input asp-for="annumlis" class="form-control" />
<span asp-validation-for="annumlis" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="andtobso" class="control-label"></label>
<input asp-for="andtobso" class="form-control" />
<span asp-validation-for="andtobso" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>