METODO PER CREAZIONE SERIALE IN ANAGRAFICA
This commit is contained in:
parent
8711248cf0
commit
0533a6678e
@ -1,5 +1,6 @@
|
|||||||
using Humanizer;
|
using Humanizer;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NuGet.Common;
|
using NuGet.Common;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -19,6 +20,7 @@ namespace VirtualTask.Controllers
|
|||||||
string tenant = string.Empty;
|
string tenant = string.Empty;
|
||||||
string errMes = string.Empty;
|
string errMes = string.Empty;
|
||||||
HttpClient client;
|
HttpClient client;
|
||||||
|
string _serchiam = "SER_ANAGRA";
|
||||||
|
|
||||||
public AnagController()
|
public AnagController()
|
||||||
{
|
{
|
||||||
@ -104,7 +106,7 @@ namespace VirtualTask.Controllers
|
|||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
client.BaseAddress = baseAddress;
|
client.BaseAddress = baseAddress;
|
||||||
|
model.ancodice = getNewSeriale();
|
||||||
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;
|
||||||
@ -313,5 +315,34 @@ namespace VirtualTask.Controllers
|
|||||||
string e = helper.GetStringValue("errMsg");
|
string e = helper.GetStringValue("errMsg");
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e });
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string getNewSeriale()
|
||||||
|
{
|
||||||
|
int p = -1;
|
||||||
|
string seriale = string.Empty;
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
token = helper.GetStringValue("tok");
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "progressiviList";
|
||||||
|
urlBase = urlBase + "?token=" + token;
|
||||||
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = baseAddress;
|
||||||
|
List<Progressivo> progressivi = new List<Progressivo>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string data = response.Content.ReadAsStringAsync().Result;
|
||||||
|
progressivi = JsonConvert.DeserializeObject<List<Progressivo>>(data);
|
||||||
|
var last= progressivi.Where(t=>t.tipo_prog.Equals(_serchiam)).First();
|
||||||
|
p = last.val_prog;
|
||||||
|
p++;
|
||||||
|
seriale=Convert.ToString(p);
|
||||||
|
seriale = seriale.PadLeft(10, '0');
|
||||||
|
}
|
||||||
|
//todo AGGIORNO IL VALORE DEL PROGRESSIVO
|
||||||
|
|
||||||
|
return seriale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
Models/Progressivo.cs
Normal file
14
Models/Progressivo.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace VirtualTask.Models
|
||||||
|
{
|
||||||
|
public class Progressivo
|
||||||
|
{
|
||||||
|
/// <summary>Azienda</summary>
|
||||||
|
public string? azienda { get; set; }
|
||||||
|
|
||||||
|
/// <summary>stringa definisce il tipo di progressivo da gestire</summary>
|
||||||
|
public string? tipo_prog { get; set; }
|
||||||
|
|
||||||
|
/// <summary>valore progressivo</summary>
|
||||||
|
public int val_prog { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user