1485 lines
66 KiB
C#
1485 lines
66 KiB
C#
using ApiSoftway.Models;
|
|
using ApiSoftway.Models.Gesa_DbContext;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security.Claims;
|
|
using System.Text;
|
|
|
|
namespace ApiSoftway.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class GiriController : ControllerBase
|
|
{
|
|
private readonly ILogger<LoginController> _logger;
|
|
private readonly GESA_GIRI_DbContext _giri_context;
|
|
private readonly GESA_GIRICONSEGNE_DbContext _giricons_context;
|
|
private readonly GESA_DESTINAZIONI_DbContext _destinazioni_context;
|
|
private readonly GESA_CONSEGNE_DbContext _consegne_context;
|
|
private readonly GESA_GIRICONSEGNEVISTA_DbContext _consegnevista_context;
|
|
private readonly GESA_SBR_ORD_DbContext _sbrord_context;
|
|
private readonly GESA_PERSONALE_DbContext _personale_context;
|
|
private readonly GESA_AUTOMEZZI_DbContext _automezzi_context;
|
|
private readonly IConfiguration? _configuration;
|
|
private readonly GESA_GIRICONSEGNEDACREARE_DbContext _daCreare_context;
|
|
private readonly GESA_CONSEGNE_M_DbContext _consegne_m_context;
|
|
private readonly GESA_PI_GIRI_SERIALI_DbContext _giriseriali_context;
|
|
private readonly GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext _daCreareDest_context;
|
|
private readonly GESA_DESTINAZIONI_WEB_DbContext _destinazioni_web_context;
|
|
private readonly GESA_GIRI_TESTATE_DbContext _giri_testate_context;
|
|
private readonly GESA_SBR_ORD_TABLE_DbContext _sbrordTable_context;
|
|
|
|
private DbSet<Giri>? _giri;
|
|
private DbSet<GiriConsegna>? _giriCons;
|
|
private DbSet<GiriConsegnaView>? _giriConsView;
|
|
private DbSet<Destinazioni>? _destinazioni;
|
|
private DbSet<ConsegnaTable>? _consegne;
|
|
private DbSet<Sbr_ord>? _sbrord;
|
|
private DbSet<Personale>? _personale;
|
|
private DbSet<Automezzi>? _automezzi;
|
|
private DbSet<GiriConsegnaDaCreare>? _GiriDaCreare;
|
|
private DbSet<Consegna_m>? _testate;
|
|
private DbSet<GiriConsegnaDaCreareDest>? _GiriDaCreareDest;
|
|
private DbSet<Sbr_ordTable>? _sbrordTable;
|
|
public GiriController(ILogger<LoginController> logger, IConfiguration? configuration, GESA_GIRI_DbContext giri_context, GESA_DESTINAZIONI_DbContext destinazioni_context
|
|
, GESA_CONSEGNE_DbContext consegne_context, GESA_GIRICONSEGNE_DbContext giricons_context, GESA_GIRICONSEGNEVISTA_DbContext consegnevista_context, GESA_SBR_ORD_DbContext sbrord_context
|
|
, GESA_PERSONALE_DbContext personale_context, GESA_AUTOMEZZI_DbContext automezzi_context, GESA_GIRICONSEGNEDACREARE_DbContext daCreare_context
|
|
, GESA_CONSEGNE_M_DbContext consegne_m_context, GESA_PI_GIRI_SERIALI_DbContext giriseriali_context, GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext daCreareDest_context
|
|
, GESA_DESTINAZIONI_WEB_DbContext destinazioni_web_context,GESA_GIRI_TESTATE_DbContext giri_testate_context, GESA_SBR_ORD_TABLE_DbContext sbrordTable_context)
|
|
{
|
|
_logger = logger;
|
|
_configuration = configuration;
|
|
_giri_context = giri_context;
|
|
_destinazioni_context = destinazioni_context;
|
|
_consegne_context = consegne_context;
|
|
_giricons_context = giricons_context;
|
|
_consegnevista_context = consegnevista_context;
|
|
_sbrord_context = sbrord_context;
|
|
_personale_context= personale_context;
|
|
_automezzi_context = automezzi_context;
|
|
_daCreare_context = daCreare_context;
|
|
_consegne_m_context = consegne_m_context;
|
|
_giriseriali_context = giriseriali_context;
|
|
_daCreareDest_context = daCreareDest_context;
|
|
_destinazioni_web_context = destinazioni_web_context;
|
|
_giri_testate_context = giri_testate_context;
|
|
_sbrordTable_context = sbrordTable_context;
|
|
}
|
|
|
|
[HttpGet("listaGiri")]
|
|
public async Task<ActionResult<IEnumerable<GiriConsegnaView>>> listaGiri(string? autista, DateTime? data, bool aperto=true)
|
|
{
|
|
|
|
List<GiriConsegnaView> lst = new List<GiriConsegnaView>();
|
|
_giriConsView = _consegnevista_context.GiriView;
|
|
var gc= aperto?await _giriConsView.Where(t=>t.DataChiusura==null).OrderByDescending(t => t.DataGiro).ToListAsync(): await _giriConsView.Where(t => t.DataChiusura != null).OrderByDescending(t => t.DataGiro).ToListAsync();
|
|
|
|
if(data!=null)
|
|
{
|
|
gc= gc.Where(t=>t.DataGiro!=null && t.DataGiro==data).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty( autista))
|
|
{
|
|
gc = gc.Where(t => t.CodAutista != null && t.CodAutista.Trim().Equals(autista.Trim())).ToList();
|
|
}
|
|
|
|
return gc;
|
|
}
|
|
|
|
[HttpGet("listaGiriDaCreare")]
|
|
public async Task<ActionResult<IEnumerable<GiriConsegnaDaCreare>>> listaGiriDaCreare()
|
|
{
|
|
List<GiriConsegnaDaCreare> lst = new List<GiriConsegnaDaCreare>();
|
|
_GiriDaCreare = _daCreare_context.GiriDaCreare;
|
|
var gc = await _GiriDaCreare.OrderByDescending(t => t.DataGiro).ToListAsync() ;
|
|
|
|
return gc;
|
|
}
|
|
|
|
[HttpGet("listaGiriDaCreareByData")]
|
|
public async Task<ActionResult<IEnumerable<GiriConsegnaDaCreare>>> listaGiriDaCreareByData(DateTime dt)
|
|
{
|
|
List<GiriConsegnaDaCreare> lst = new List<GiriConsegnaDaCreare>();
|
|
_GiriDaCreare = _daCreare_context.GiriDaCreare;
|
|
var gc = await _GiriDaCreare.Where(t=>t.DataGiro.Equals(dt)).OrderByDescending(t => t.DataGiro).ToListAsync();
|
|
|
|
return gc;
|
|
}
|
|
|
|
[HttpGet("listaAutisti")]
|
|
public async Task<ActionResult<IEnumerable<Personale>>> listaAutisti()
|
|
{
|
|
_personale = _personale_context.Personale;
|
|
//var pers = await _personale.Where(t => t.Tcuser != null && t.Tcpwd != null && t.Tcruolo!=null && t.Tcruolo.Equals("AUT")).ToListAsync();
|
|
var pers = await _personale.Where(t => t.Tcruolo.Equals("AUT")).ToListAsync();
|
|
return pers;
|
|
}
|
|
|
|
[HttpGet("listaAutomezzi")]
|
|
public async Task<ActionResult<IEnumerable<Automezzi>>> listaAutomezzi()
|
|
{
|
|
_automezzi = _automezzi_context.Automezzi;
|
|
var aut = await _automezzi.ToListAsync();
|
|
return aut;
|
|
}
|
|
|
|
[HttpGet("brogliaccio")]
|
|
public async Task<ActionResult<IEnumerable<Sbr_ord>>> brogliaccio()
|
|
{
|
|
_sbrord = _sbrord_context.Cons;
|
|
var bro = await _sbrord.ToListAsync();
|
|
return bro;
|
|
}
|
|
|
|
///// <summary>Salva i dati della consegna</summary>
|
|
//[HttpPost]
|
|
//[Route("addGiro")]
|
|
//public async Task<ActionResult<GiriConsegna_out>> addGiro(string? autista,int? bancali, decimal? importo, DateTime? data)
|
|
//{
|
|
// GiriConsegna_out tOut = new GiriConsegna_out();
|
|
// //string usr = getClaimValueByToken(token, "codice");
|
|
// try
|
|
// {
|
|
// //step 1 : calcolo il nuovo seriale
|
|
// _giriConsView = _consegnevista_context.GiriView;
|
|
// var ser= await _giriConsView.Take(1).OrderByDescending(t => t.SerialeGiro).ToListAsync();
|
|
// string ultSer = ser.First().SerialeGiro;
|
|
// string newSer = calcolaNuovoSeriale(ultSer);
|
|
|
|
// //step 2 : inserisco in PIGIRCON
|
|
// GiriConsegna gc=new GiriConsegna();
|
|
// gc.Piautist = autista;
|
|
// gc.Pitbancar = bancali;
|
|
// gc.Pidata = data;
|
|
// gc.Pisergir = newSer;
|
|
// gc.Pidarecu = importo;
|
|
// using (var transactionGiri = _giricons_context.Database.BeginTransaction())
|
|
// {
|
|
// await _giricons_context.GiriCons.AddAsync(gc);
|
|
// await _giricons_context.SaveChangesAsync();
|
|
// transactionGiri.Commit();
|
|
// }
|
|
|
|
// //step 3 aggiorno con il seriale le righe delle destinazioni
|
|
// _destinazioni = _destinazioni_context.Destinazioni;
|
|
// var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == data && t.serialeGiro==null).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
// foreach(Destinazioni d in dest)
|
|
// {
|
|
// Sbr_ord sbr_Ord = new Sbr_ord();
|
|
// sbr_Ord.Brserial = d.Brserial;
|
|
// sbr_Ord.Pisergir = newSer;
|
|
// using (var transactionDest = _sbrord_context.Database.BeginTransaction())
|
|
// {
|
|
// _sbrord_context.Entry(sbr_Ord).State = EntityState.Modified;
|
|
// await _sbrord_context.SaveChangesAsync();
|
|
// transactionDest.Commit();
|
|
// }
|
|
// }
|
|
|
|
// var giro = await _giriConsView.Where(t=>t.SerialeGiro.Equals(newSer)).ToListAsync();
|
|
// return StatusCode(StatusCodes.Status200OK, giro.First());
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
// tOut.err_title = ex.Message;
|
|
// tOut.err_detail = errmsg;
|
|
// tOut.err_status_code = "500";
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
// }
|
|
//}
|
|
|
|
[HttpPost]
|
|
[Route("addGiro2")]
|
|
public async Task<ActionResult<GiriConsegna_out>> addGiro2([FromBody] GiriConsegnaView model)
|
|
{
|
|
GiriConsegna_out tOut = new GiriConsegna_out();
|
|
//string usr = getClaimValueByToken(token, "codice");
|
|
try
|
|
{
|
|
//step 1 : calcolo il nuovo seriale
|
|
_giriConsView = _consegnevista_context.GiriView;
|
|
var ser = await _giriConsView.Take(1).OrderByDescending(t => t.SerialeGiro).ToListAsync();
|
|
string ultSer = "0";
|
|
if (ser!=null && ser.Count>0)
|
|
{
|
|
ultSer = ser.First().SerialeGiro;
|
|
}
|
|
|
|
string newSer = calcolaNuovoSeriale(ultSer);
|
|
|
|
//step 2 : inserisco in PIGIRCON
|
|
GiriConsegna gc = new GiriConsegna();
|
|
gc.Piautist = model.CodAutista;
|
|
gc.Pitbancar = model.BancaliCaricati;
|
|
gc.Pidata = model.DataGiro;
|
|
gc.Pisergir = newSer;
|
|
gc.Pidarecu = model.ImportoDaRecuperare;
|
|
gc.Pimezzo = model.CodMezzo;
|
|
using (var transactionGiri = _giricons_context.Database.BeginTransaction())
|
|
{
|
|
await _giricons_context.GiriCons.AddAsync(gc);
|
|
await _giricons_context.SaveChangesAsync();
|
|
transactionGiri.Commit();
|
|
}
|
|
|
|
//step 3 aggiorno con il seriale le righe delle destinazioni
|
|
|
|
//_destinazioni = _destinazioni_context.Destinazioni;
|
|
//var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(model.CodAutista)
|
|
//&& t.DataCarico != null && t.DataCarico == model.DataGiro
|
|
////&& t.serialeGiro == null
|
|
//&& t.CodAutomezzo!=null && t.CodAutomezzo.Equals(model.CodMezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
|
|
|
|
|
|
_destinazioni = _daCreareDest_context.GiriDaCreare;
|
|
var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(model.CodAutista)
|
|
&& t.DataCarico != null && t.DataCarico == model.DataGiro
|
|
//&& t.serialeGiro == null
|
|
&& t.CodAutomezzo != null && t.CodAutomezzo.Equals(model.CodMezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
|
|
foreach (Destinazioni d in dest)
|
|
{
|
|
//20241018: cambiato sistema inserisco in tabella di raccordo GESAPI_GIRI_SERIALI
|
|
GiriSeriali g =new GiriSeriali();
|
|
g.Brserial = d.Brserial;
|
|
g.Pisergir = newSer;
|
|
using (var transactionDest = _giriseriali_context.Database.BeginTransaction())
|
|
{
|
|
await _giriseriali_context.Cons.AddAsync(g);
|
|
await _giriseriali_context.SaveChangesAsync();
|
|
transactionDest.Commit();
|
|
}
|
|
/*
|
|
Sbr_ord sbr_Ord = new Sbr_ord();
|
|
sbr_Ord.Brserial = d.Brserial;
|
|
sbr_Ord.Pisergir = newSer;
|
|
//ATTENZIONE!! fa l'aggiornamento su tutti i campi dell'oggetto
|
|
|
|
using (var transactionDest = _sbrord_context.Database.BeginTransaction())
|
|
{
|
|
//_sbrord_context.Entry(sbr_Ord).State = EntityState.Modified;
|
|
_sbrord_context.Entry(sbr_Ord).Property(x => x.Pisergir).IsModified = true;
|
|
|
|
await _sbrord_context.SaveChangesAsync();
|
|
transactionDest.Commit();
|
|
}
|
|
*/
|
|
}
|
|
|
|
var giro = await _giriConsView.Where(t => t.SerialeGiro.Equals(newSer)).ToListAsync();
|
|
return StatusCode(StatusCodes.Status200OK, giro.First());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
tOut.err_title = ex.Message;
|
|
tOut.err_detail = errmsg;
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("addBrogliaccio")]
|
|
public async Task<ActionResult<string>> addBrogliaccio(string token, DateTime? oldData,DateTime? newData)
|
|
{
|
|
string msg = string.Empty;
|
|
|
|
try
|
|
{
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
if (!string.IsNullOrEmpty(usr) && usr.Trim().Equals("TEST"))
|
|
{
|
|
//step 1 : prendo gli ultimi 1000 record della tabella SBR_ORD
|
|
_sbrordTable = _sbrordTable_context.Cons;
|
|
int tot = _sbrordTable.Count();
|
|
msg = tot.ToString();
|
|
|
|
var bro = await _sbrordTable.Where(t => t.Brdatcar == oldData
|
|
&& !string.IsNullOrEmpty(t.Brautist.Trim())
|
|
&& (t.Brqtacol != null && t.Brqtacol > 0
|
|
|| (t.Brqtavol != null && t.Brqtavol > 0)
|
|
|| (t.Brcolprev != null && t.Brcolprev > 0)
|
|
|| (t.Brconspr != null && t.Brconspr > 0)
|
|
|| (t.Bruovapr != null && t.Bruovapr > 0)
|
|
|| (t.Brcistpr != null && t.Brcistpr > 0)
|
|
|| (!string.IsNullOrEmpty(t.Brnote))
|
|
)
|
|
).ToListAsync();
|
|
|
|
int counter = 0;
|
|
foreach (Sbr_ordTable d in bro)
|
|
{
|
|
string newSerial = getCpccchk(10);
|
|
d.Brserial = newSerial;
|
|
d.cpccchk = newSerial;
|
|
d.Brdatcar = newData;
|
|
d.BRDATINS = newData != null ? newData.Value.AddDays(-1) : DateTime.Now;
|
|
d.BRDATVAR = newData != null ? newData.Value.AddDays(-1) : DateTime.Now;
|
|
d.BRDATSCA = newData;
|
|
string nota= "*****" + newData.ToString() + d.Brnote;
|
|
if(nota.Length>50)
|
|
{
|
|
nota = nota.Substring(0, 50);
|
|
}
|
|
d.Brnote = nota;
|
|
|
|
using (var transactionDest = _sbrordTable_context.Database.BeginTransaction())
|
|
{
|
|
await _sbrordTable_context.Cons.AddAsync(d);
|
|
await _sbrordTable_context.SaveChangesAsync();
|
|
transactionDest.Commit();
|
|
}
|
|
counter++;
|
|
}
|
|
msg = "Inseriti " + counter.ToString() + " record";
|
|
return StatusCode(StatusCodes.Status200OK, msg);
|
|
}
|
|
else
|
|
{
|
|
return StatusCode(StatusCodes.Status200OK, "Impossibile procedere al caricamento. Utente non abilitato all'operazione");
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
return StatusCode(StatusCodes.Status500InternalServerError, msg);
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("closeGiro")]
|
|
public async Task<ActionResult<GiriConsegna_out>> closeGiro(string? serialeGiro, int? bancaliRecuperati, decimal? importoRecuperato)
|
|
{
|
|
GiriConsegna_out tOut = new GiriConsegna_out();
|
|
//string usr = getClaimValueByToken(token, "codice");
|
|
try
|
|
{
|
|
//step 1 : calcolo il nuovo seriale
|
|
_giriConsView = _consegnevista_context.GiriView;
|
|
var giro = await _giriConsView.Where(t=>t.SerialeGiro!=null && t.SerialeGiro.Equals(serialeGiro)).FirstAsync();
|
|
|
|
GiriConsegna gc=new GiriConsegna();
|
|
gc.Pisergir = giro.SerialeGiro;
|
|
gc.Pidarecu = giro.ImportoDaRecuperare;
|
|
gc.Piautist = giro.CodAutista;
|
|
gc.Pirecupe = importoRecuperato;
|
|
gc.Pidata = giro.DataGiro;
|
|
gc.Pidatchi = DateTime.Now;
|
|
gc.Pitbancar = giro.BancaliCaricati;
|
|
gc.Pitbanrec=bancaliRecuperati;
|
|
gc.Pimezzo = giro.CodMezzo;
|
|
|
|
|
|
using (var transactionGiri = _giricons_context.Database.BeginTransaction())
|
|
{
|
|
_giricons_context.Entry(gc).State = EntityState.Modified;
|
|
await _giricons_context.SaveChangesAsync();
|
|
transactionGiri.Commit();
|
|
}
|
|
|
|
|
|
giro = await _giriConsView.Where(t => t.SerialeGiro != null && t.SerialeGiro.Equals(serialeGiro)).FirstAsync();
|
|
tOut.Pisergir = giro.SerialeGiro;
|
|
tOut.Pirecupe = giro.ImportoRecuperato;
|
|
tOut.Pidarecu=giro.ImportoDaRecuperare;
|
|
tOut.Piautist=giro.CodAutista;
|
|
tOut.Pidata = giro.DataGiro;
|
|
tOut.Pidatchi = giro.DataChiusura;
|
|
tOut.Pitbancar = giro.BancaliCaricati;
|
|
tOut.Pitbanrec = giro.BancaliRecuperati;
|
|
|
|
|
|
return StatusCode(StatusCodes.Status200OK, tOut);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
tOut.err_title = ex.Message;
|
|
tOut.err_detail = errmsg;
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("modGiro")]
|
|
public async Task<ActionResult<GiriConsegna_out>> modGiro(GiriConsegnaView model)
|
|
{
|
|
GiriConsegna_out tOut = new GiriConsegna_out();
|
|
|
|
try
|
|
{
|
|
//step 1 : calcolo il nuovo seriale
|
|
|
|
GiriConsegna gc = new GiriConsegna();
|
|
gc.Pisergir = model.SerialeGiro;
|
|
gc.Pidarecu = model.ImportoDaRecuperare;
|
|
gc.Piautist = model.CodAutista;
|
|
gc.Pirecupe = model.ImportoRecuperato;
|
|
gc.Pidata = model.DataGiro;
|
|
gc.Pidatchi = null;
|
|
gc.Pitbancar = model.BancaliCaricati;
|
|
gc.Pitbanrec = null;
|
|
gc.Pimezzo = model.CodMezzo;
|
|
|
|
using (var transactionGiri = _giricons_context.Database.BeginTransaction())
|
|
{
|
|
_giricons_context.Entry(gc).State = EntityState.Modified;
|
|
await _giricons_context.SaveChangesAsync();
|
|
transactionGiri.Commit();
|
|
}
|
|
_giriConsView = _consegnevista_context.GiriView;
|
|
var giro = await _giriConsView.Where(t => t.SerialeGiro != null && t.SerialeGiro.Equals(model.SerialeGiro)).FirstAsync();
|
|
tOut.Pisergir = giro.SerialeGiro;
|
|
tOut.Pirecupe = giro.ImportoRecuperato;
|
|
tOut.Pidarecu = giro.ImportoDaRecuperare;
|
|
tOut.Piautist = giro.CodAutista;
|
|
tOut.Pidata = giro.DataGiro;
|
|
tOut.Pidatchi = giro.DataChiusura;
|
|
tOut.Pitbancar = giro.BancaliCaricati;
|
|
tOut.Pitbanrec = giro.BancaliRecuperati;
|
|
|
|
|
|
return StatusCode(StatusCodes.Status200OK, tOut);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
tOut.err_title = ex.Message;
|
|
tOut.err_detail = errmsg;
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("delGiro")]
|
|
public async Task<ActionResult<GiriConsegna_out>> delGiro(string? serialeGiro, string? autista, DateTime? data)
|
|
{
|
|
GiriConsegna_out tOut = new GiriConsegna_out();
|
|
//string usr = getClaimValueByToken(token, "codice");
|
|
try
|
|
{
|
|
//step 1 : controllo che si possa cancellare
|
|
_destinazioni = _destinazioni_context.Destinazioni;
|
|
var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == data ).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
if (r.Count() > 0)
|
|
{
|
|
var destFatte = r.Where(x => x.consFattaSerial != null).ToList();
|
|
if (destFatte.Count > 0)
|
|
{
|
|
//messaggio di errore
|
|
tOut.err_title = "Impossibile eliminare";
|
|
tOut.err_detail = "Impossibile eliminare il giro. Alcune consegne sono state già effettuate";
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
else
|
|
{
|
|
//step 2 : aggiorno le destinazioni cancellando il seriale del giro
|
|
var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == data && t.serialeGiro != null).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
foreach (Destinazioni d in dest)
|
|
{
|
|
Sbr_ord sbr_Ord = new Sbr_ord();
|
|
sbr_Ord.Brserial = d.Brserial;
|
|
sbr_Ord.Pisergir = null;
|
|
using (var transactionDest = _sbrord_context.Database.BeginTransaction())
|
|
{
|
|
_sbrord_context.Entry(sbr_Ord).State = EntityState.Modified;
|
|
await _sbrord_context.SaveChangesAsync();
|
|
transactionDest.Commit();
|
|
}
|
|
}
|
|
//step 3 : cancello il giro
|
|
GiriConsegna model=new GiriConsegna();
|
|
model.Pisergir = serialeGiro;
|
|
using (var transaction = _giricons_context.Database.BeginTransaction())
|
|
{
|
|
_giricons_context.Entry(model).State = EntityState.Deleted;
|
|
await _giricons_context.SaveChangesAsync();
|
|
transaction.Commit();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//il giro cretao non ha destinazioni associate. cancello solo il record detro pigircon
|
|
GiriConsegna model = new GiriConsegna();
|
|
model.Pisergir = serialeGiro;
|
|
using (var transaction = _giricons_context.Database.BeginTransaction())
|
|
{
|
|
_giricons_context.Entry(model).State = EntityState.Deleted;
|
|
await _giricons_context.SaveChangesAsync();
|
|
transaction.Commit();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return StatusCode(StatusCodes.Status200OK, tOut);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
tOut.err_title = ex.Message;
|
|
tOut.err_detail = errmsg;
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
}
|
|
|
|
//metodo app
|
|
[HttpGet("listaDestinazioni")]
|
|
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioni2(string token,DateTime? dataGiro)
|
|
{
|
|
DateTime? data;
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
bool btnChiudiVisible = true;
|
|
bool btnNonChiudiVisible = true;
|
|
List<Destinazioni> lstDest=new List<Destinazioni>();
|
|
List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
|
|
|
if (dataGiro == null)
|
|
{
|
|
data = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
data= dataGiro;
|
|
}
|
|
|
|
if (data != DateTime.Today)
|
|
{
|
|
//Sto visualizzando le destinazioni FUTURE che non posso consegnare
|
|
//la data è diversa dalla data odierna: disabilito i bottoni e cerco le destinazioni tra quelle che che NON sono state validate
|
|
//e che quindi NON hanno caricato i bancali (serialeGiro nullo)
|
|
btnChiudiVisible = false;
|
|
btnNonChiudiVisible = false;
|
|
|
|
_destinazioni = _daCreareDest_context.GiriDaCreare;
|
|
lstDest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(usr)
|
|
&& t.DataCarico != null && t.DataCarico == dataGiro).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
|
|
string serFake = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
//devo valorizzare un seriale giro fake per rispettare l'ordinamento/filtro che faccio sotto
|
|
foreach (Destinazioni d in lstDest)
|
|
{
|
|
|
|
d.serialeGiro = serFake;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Sto visualizzando le destinazioni di OGGI che devo lavorare
|
|
// sono nella data odierna: devo far vedere SOLO le destinazioni validate con i bancali caricati (serialeGiro NON nullo)
|
|
_destinazioni = _destinazioni_context.Destinazioni;
|
|
lstDest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(usr) && t.DataCarico != null && t.DataCarico == data
|
|
&& !string.IsNullOrEmpty(t.serialeGiro)).OrderBy(t => t.serialeGiro).ToListAsync();
|
|
}
|
|
|
|
//2024-07-29: se un autista ha due o più giri da fare nello stesso giorno li devo separare. li ho ordinati per seriale giro e gli do quelli del primo
|
|
// giro disponibile che non sia chiuso (PIDATCHI di GESAPIGIRCON deve essere nulla)
|
|
int giro = 0;
|
|
string seriale_attuale = string.Empty;
|
|
foreach (Destinazioni d in lstDest)
|
|
{
|
|
if(giro==0)
|
|
{
|
|
seriale_attuale = d.serialeGiro;
|
|
}
|
|
giro++;
|
|
|
|
if(d.serialeGiro.Equals(seriale_attuale))
|
|
{
|
|
Destinazioni_out o = new Destinazioni_out();
|
|
string _aut= !string.IsNullOrEmpty(d.Autista) ? d.Autista.Trim() : string.Empty;
|
|
o.Autista = _aut;
|
|
|
|
string _autCod = !string.IsNullOrEmpty(d.CodAutista) ? d.CodAutista.Trim() : string.Empty;
|
|
o.CodAutista = _autCod;
|
|
|
|
string _automezzo = !string.IsNullOrEmpty(d.DescAutomezzo) ? d.DescAutomezzo.Trim() : string.Empty;
|
|
o.DescAutomezzo = _automezzo;
|
|
|
|
string _automezzoCod = !string.IsNullOrEmpty(d.CodAutomezzo) ? d.CodAutomezzo.Trim() : string.Empty;
|
|
o.CodAutomezzo = d.CodAutomezzo;
|
|
|
|
o.DataCarico = d.DataCarico;
|
|
o.Brserial = d.Brserial;
|
|
o.Brmerce = d.Brmerce;
|
|
o.Brnote = d.Brnote;
|
|
o.Cproword = d.Cproword;
|
|
o.Cprownum=d.Cprownum;
|
|
|
|
string _sedeInd = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
|
|
o.IndirizzoSede = _sedeInd;
|
|
|
|
string _sede = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
|
|
o.Sede = _sede;
|
|
o.CodCommittente = d.CodCommittente;
|
|
|
|
string _committente = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
|
|
o.Committente = _committente;
|
|
|
|
o.CodSede = d.CodSede;
|
|
o.ItemList = formattaDestinazione(d);
|
|
o.ImportoDaRitirare = d.ImportoDaRitirare;
|
|
o.serialeGiro=d.serialeGiro;
|
|
o.Casse = d.Casse;
|
|
o.Trasf=d.Trasf;
|
|
o.Colli=d.Colli;
|
|
o.num_cons = d.num_cons;
|
|
o.Uova=d.Uova;
|
|
o.Cist=d.Cist;
|
|
o.Note = d.Note;
|
|
o.Seq = d.Seq;
|
|
o.Prog = d.Prog;
|
|
|
|
//2025-03.19 - flag pulsanti visibili: se data passata = data odierna pulsanti visibili altrimenti no
|
|
o.BtnChiudiVisible= btnChiudiVisible;
|
|
o.BtnNonChiudiVisible = btnNonChiudiVisible;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(d.consFattaSerial))
|
|
{
|
|
ConsegnaFatta cf=new ConsegnaFatta();
|
|
cf.consFattaSerial= d.consFattaSerial;
|
|
cf.consFattaRow= d.consFattaRow;
|
|
cf.consFattaAut= d.consFattaAut;
|
|
cf.consFattaBanSca = d.consFattaBanSca;
|
|
cf.consFattaBanCar= d.consFattaBanCar;
|
|
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
|
|
cf.consFattaNotBan= nota;
|
|
cf.consFattaImpor=d.consFattaImpor;
|
|
cf.consFattaMezzo= d.consFattaMezzo;
|
|
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
|
|
cf.consFattaNotImp=nota2;
|
|
cf.consFattaFlagCons=d.consFattaFlagCons;
|
|
cf.consFattaDataOra = d.consFattaDataOra;
|
|
|
|
o.ConsFatta=cf;
|
|
}
|
|
|
|
lst.Add(o);
|
|
}
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
[HttpGet("listaDestinazioniByAutistaDataMezzo")]
|
|
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioniByAutistaData(string autista, DateTime? dataGiro,string mezzo)
|
|
{
|
|
|
|
List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
|
_destinazioni = _destinazioni_context.Destinazioni;
|
|
var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro && t.CodAutomezzo!=null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ThenBy(t=>t.Seq).ToListAsync();
|
|
foreach (Destinazioni d in r)
|
|
{
|
|
Destinazioni_out o = new Destinazioni_out();
|
|
string _aut = !string.IsNullOrEmpty(d.Autista) ? d.Autista.Trim() : string.Empty;
|
|
o.Autista = _aut;
|
|
|
|
string _autCod = !string.IsNullOrEmpty(d.CodAutista) ? d.CodAutista.Trim() : string.Empty;
|
|
o.CodAutista = _autCod;
|
|
|
|
string _automezzo = !string.IsNullOrEmpty(d.DescAutomezzo) ? d.DescAutomezzo.Trim() : string.Empty;
|
|
o.DescAutomezzo = _automezzo;
|
|
|
|
string _automezzoCod = !string.IsNullOrEmpty(d.CodAutomezzo) ? d.CodAutomezzo.Trim() : string.Empty;
|
|
o.CodAutomezzo = d.CodAutomezzo;
|
|
|
|
o.DataCarico = d.DataCarico;
|
|
o.Brserial = d.Brserial;
|
|
o.Brmerce = d.Brmerce;
|
|
o.Brnote = d.Brnote;
|
|
o.Cproword = d.Cproword;
|
|
o.Cprownum = d.Cprownum;
|
|
|
|
string _sedeInd = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
|
|
o.IndirizzoSede = _sedeInd;
|
|
|
|
string _sede = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
|
|
o.Sede = _sede;
|
|
o.CodCommittente = d.CodCommittente;
|
|
|
|
string _committente = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
|
|
o.Committente = _committente;
|
|
|
|
o.CodSede = d.CodSede;
|
|
o.ItemList = formattaDestinazione(d);
|
|
o.ImportoDaRitirare = d.ImportoDaRitirare;
|
|
o.serialeGiro = d.serialeGiro;
|
|
o.Casse=d.Casse;
|
|
o.Trasf=d.Trasf;
|
|
o.Colli=d.Colli;
|
|
o.num_cons = d.num_cons;
|
|
o.Uova=d.Uova;
|
|
o.Cist=d.Cist;
|
|
o.Note = d.Note;
|
|
o.Seq = d.Seq;
|
|
o.Prog = d.Prog;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(d.consFattaSerial))
|
|
{
|
|
ConsegnaFatta cf = new ConsegnaFatta();
|
|
cf.consFattaSerial = d.consFattaSerial;
|
|
cf.consFattaRow = d.consFattaRow;
|
|
cf.consFattaAut = d.consFattaAut;
|
|
cf.consFattaBanSca = d.consFattaBanSca;
|
|
cf.consFattaBanCar = d.consFattaBanCar;
|
|
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
|
|
cf.consFattaNotBan = nota;
|
|
cf.consFattaImpor = d.consFattaImpor;
|
|
cf.consFattaMezzo = d.consFattaMezzo;
|
|
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
|
|
cf.consFattaNotImp = nota2;
|
|
cf.consFattaFlagCons = d.consFattaFlagCons;
|
|
cf.consFattaDataOra = d.consFattaDataOra;
|
|
|
|
o.ConsFatta = cf;
|
|
}
|
|
|
|
lst.Add(o);
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
[HttpGet("listaDestinazioniByAutistaDataMezzoWeb")]
|
|
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioniByAutistaDataWeb(string autista, DateTime? dataGiro, string mezzo)
|
|
{
|
|
List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
|
_destinazioni = _destinazioni_web_context.Destinazioni;
|
|
var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro && t.CodAutomezzo != null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).ToListAsync();
|
|
foreach (Destinazioni d in r)
|
|
{
|
|
Destinazioni_out o = new Destinazioni_out();
|
|
string _aut = !string.IsNullOrEmpty(d.Autista) ? d.Autista.Trim() : string.Empty;
|
|
o.Autista = _aut;
|
|
|
|
string _autCod = !string.IsNullOrEmpty(d.CodAutista) ? d.CodAutista.Trim() : string.Empty;
|
|
o.CodAutista = _autCod;
|
|
|
|
string _automezzo = !string.IsNullOrEmpty(d.DescAutomezzo) ? d.DescAutomezzo.Trim() : string.Empty;
|
|
o.DescAutomezzo = _automezzo;
|
|
|
|
string _automezzoCod = !string.IsNullOrEmpty(d.CodAutomezzo) ? d.CodAutomezzo.Trim() : string.Empty;
|
|
o.CodAutomezzo = d.CodAutomezzo;
|
|
|
|
o.DataCarico = d.DataCarico;
|
|
o.Brserial = d.Brserial;
|
|
o.Brmerce = d.Brmerce;
|
|
o.Brnote = d.Brnote;
|
|
o.Cproword = d.Cproword;
|
|
o.Cprownum = d.Cprownum;
|
|
|
|
string _sedeInd = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
|
|
o.IndirizzoSede = _sedeInd;
|
|
|
|
string _sede = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
|
|
o.Sede = _sede;
|
|
o.CodCommittente = d.CodCommittente;
|
|
|
|
string _committente = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
|
|
o.Committente = _committente;
|
|
|
|
o.CodSede = d.CodSede;
|
|
o.ItemList = formattaDestinazione(d);
|
|
o.ImportoDaRitirare = d.ImportoDaRitirare;
|
|
o.serialeGiro = d.serialeGiro;
|
|
o.Casse = d.Casse;
|
|
o.Trasf = d.Trasf;
|
|
o.Colli = d.Colli;
|
|
o.num_cons = d.num_cons;
|
|
o.Uova = d.Uova;
|
|
o.Cist = d.Cist;
|
|
o.Note = d.Note;
|
|
o.NoteConsegna = d.NoteConsegna;
|
|
o.Seq = d.Seq;
|
|
o.Prog = d.Prog;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(d.consFattaSerial))
|
|
{
|
|
ConsegnaFatta cf = new ConsegnaFatta();
|
|
cf.consFattaSerial = d.consFattaSerial;
|
|
cf.consFattaRow = d.consFattaRow;
|
|
cf.consFattaAut = d.consFattaAut;
|
|
cf.consFattaBanSca = d.consFattaBanSca;
|
|
cf.consFattaBanCar = d.consFattaBanCar;
|
|
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
|
|
cf.consFattaNotBan = nota;
|
|
cf.consFattaImpor = d.consFattaImpor;
|
|
cf.consFattaMezzo = d.consFattaMezzo;
|
|
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
|
|
cf.consFattaNotImp = nota2;
|
|
cf.consFattaFlagCons = d.consFattaFlagCons;
|
|
cf.consFattaDataOra = d.consFattaDataOra;
|
|
|
|
o.ConsFatta = cf;
|
|
}
|
|
|
|
lst.Add(o);
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
[HttpGet("listaDestinazioniByAutistaDataMezzoNonValidate")]
|
|
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioniByAutistaDataMezzoNonValidate(string autista, DateTime? dataGiro, string mezzo)
|
|
{
|
|
|
|
List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
|
//_destinazioni = _destinazioni_context.Destinazioni;
|
|
//var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro && t.CodAutomezzo != null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).ToListAsync();
|
|
|
|
_destinazioni = _daCreareDest_context.GiriDaCreare;
|
|
var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista)
|
|
&& t.DataCarico != null && t.DataCarico == dataGiro
|
|
//&& t.serialeGiro == null
|
|
&& t.CodAutomezzo != null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
|
|
|
|
|
|
foreach (Destinazioni d in dest)
|
|
{
|
|
Destinazioni_out o = new Destinazioni_out();
|
|
string _aut = !string.IsNullOrEmpty(d.Autista) ? d.Autista.Trim() : string.Empty;
|
|
o.Autista = _aut;
|
|
|
|
string _autCod = !string.IsNullOrEmpty(d.CodAutista) ? d.CodAutista.Trim() : string.Empty;
|
|
o.CodAutista = _autCod;
|
|
|
|
string _automezzo = !string.IsNullOrEmpty(d.DescAutomezzo) ? d.DescAutomezzo.Trim() : string.Empty;
|
|
o.DescAutomezzo = _automezzo;
|
|
|
|
string _automezzoCod = !string.IsNullOrEmpty(d.CodAutomezzo) ? d.CodAutomezzo.Trim() : string.Empty;
|
|
o.CodAutomezzo = _automezzoCod;
|
|
|
|
o.DataCarico = d.DataCarico;
|
|
o.Brserial = d.Brserial;
|
|
|
|
//step 1: leggo da sbr_ord con seriale
|
|
|
|
|
|
o.Brmerce = d.Brmerce;
|
|
o.Brnote = d.Brnote;
|
|
o.Cproword = d.Cproword;
|
|
o.Cprownum = d.Cprownum;
|
|
|
|
string _sedeInd = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
|
|
o.IndirizzoSede = _sedeInd;
|
|
|
|
string _sede = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
|
|
o.Sede = _sede;
|
|
o.CodCommittente = d.CodCommittente;
|
|
|
|
string _committente = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
|
|
o.Committente = _committente;
|
|
|
|
o.CodSede = d.CodSede;
|
|
o.ItemList = formattaDestinazione(d);
|
|
o.ImportoDaRitirare = d.ImportoDaRitirare;
|
|
o.serialeGiro = d.serialeGiro;
|
|
o.Casse = d.Casse;
|
|
o.Trasf = d.Trasf;
|
|
o.Colli = d.Colli;
|
|
o.num_cons = d.num_cons;
|
|
o.Uova = d.Uova;
|
|
o.Cist = d.Cist;
|
|
o.Note = d.Note;
|
|
o.NoteConsegna = d.NoteConsegna;
|
|
o.Seq = d.Seq;
|
|
o.Prog = d.Prog;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(d.consFattaSerial))
|
|
{
|
|
ConsegnaFatta cf = new ConsegnaFatta();
|
|
cf.consFattaSerial = d.consFattaSerial;
|
|
cf.consFattaRow = d.consFattaRow;
|
|
cf.consFattaAut = d.consFattaAut;
|
|
cf.consFattaBanSca = d.consFattaBanSca;
|
|
cf.consFattaBanCar = d.consFattaBanCar;
|
|
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
|
|
cf.consFattaNotBan = nota;
|
|
cf.consFattaImpor = d.consFattaImpor;
|
|
cf.consFattaMezzo = d.consFattaMezzo;
|
|
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
|
|
cf.consFattaNotImp = nota2;
|
|
cf.consFattaFlagCons = d.consFattaFlagCons;
|
|
cf.consFattaDataOra = d.consFattaDataOra;
|
|
|
|
o.ConsFatta = cf;
|
|
}
|
|
|
|
lst.Add(o);
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
[HttpGet("listaDestinazioneBySerial")]
|
|
public async Task<ActionResult<Destinazioni_out>> listaDestinazioneBySerial(string seriale)
|
|
{
|
|
|
|
|
|
Destinazioni_out lst = new Destinazioni_out();
|
|
_destinazioni = _destinazioni_context.Destinazioni;
|
|
//var r = await _destinazioni.Where(t => t.Brserial != null && t.Brserial.Equals(seriale)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).FirstAsync();
|
|
|
|
var r = await _destinazioni.Where(t => t.Brserial != null && t.Brserial.Equals(seriale)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).ToListAsync();
|
|
Destinazioni_out o = new Destinazioni_out();
|
|
if (r!=null && r.Count()>0)
|
|
{
|
|
string _aut = !string.IsNullOrEmpty(r.First().Autista) ? r.First().Autista.Trim() : string.Empty;
|
|
o.Autista = _aut;
|
|
|
|
string _autCod = !string.IsNullOrEmpty(r.First().CodAutista) ? r.First().CodAutista.Trim() : string.Empty;
|
|
o.CodAutista = _autCod;
|
|
|
|
string _automezzo = !string.IsNullOrEmpty(r.First().DescAutomezzo) ? r.First().DescAutomezzo.Trim() : string.Empty;
|
|
o.DescAutomezzo = _automezzo;
|
|
|
|
string _automezzoCod = !string.IsNullOrEmpty(r.First().CodAutomezzo) ? r.First().CodAutomezzo.Trim() : string.Empty;
|
|
o.CodAutomezzo = _automezzoCod;
|
|
|
|
o.DataCarico = r.First().DataCarico;
|
|
o.Brserial = r.First().Brserial;
|
|
o.Brmerce = r.First().Brmerce;
|
|
o.Brnote = r.First().Brnote;
|
|
o.Cproword = r.First().Cproword;
|
|
o.Cprownum = r.First().Cprownum;
|
|
|
|
string _sedeInd = !string.IsNullOrEmpty(r.First().IndirizzoSede) ? r.First().IndirizzoSede.Trim() : string.Empty;
|
|
o.IndirizzoSede = _sedeInd;
|
|
|
|
string _sede = !string.IsNullOrEmpty(r.First().Sede) ? r.First().Sede.Trim() : string.Empty;
|
|
o.Sede = _sede;
|
|
o.CodCommittente = r.First().CodCommittente;
|
|
|
|
string _committente = !string.IsNullOrEmpty(r.First().Committente) ? r.First().Committente.Trim() : string.Empty;
|
|
o.Committente = _committente;
|
|
|
|
o.CodSede = r.First().CodSede;
|
|
o.ItemList = formattaDestinazione(r.First());
|
|
o.ImportoDaRitirare = r.First().ImportoDaRitirare;
|
|
o.serialeGiro = r.First().serialeGiro;
|
|
o.Casse = r.First().Casse;
|
|
o.Trasf = r.First().Trasf;
|
|
o.Colli = r.First().Colli;
|
|
o.num_cons = r.First().num_cons;
|
|
o.Uova = r.First().Uova;
|
|
o.Cist = r.First().Cist;
|
|
o.Note = r.First().Note;
|
|
o.Seq = r.First().Seq;
|
|
o.Prog = r.First().Prog;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(r.First().consFattaSerial))
|
|
{
|
|
ConsegnaFatta cf = new ConsegnaFatta();
|
|
cf.consFattaSerial = r.First().consFattaSerial;
|
|
cf.consFattaRow = r.First().consFattaRow;
|
|
cf.consFattaAut = r.First().consFattaAut;
|
|
cf.consFattaBanSca = r.First().consFattaBanSca;
|
|
cf.consFattaBanCar = r.First().consFattaBanCar;
|
|
string nota = !string.IsNullOrEmpty(r.First().consFattaNotBan) ? r.First().consFattaNotBan.Trim() : string.Empty;
|
|
cf.consFattaNotBan = nota;
|
|
cf.consFattaImpor = r.First().consFattaImpor;
|
|
cf.consFattaMezzo = r.First().consFattaMezzo;
|
|
string nota2 = !string.IsNullOrEmpty(r.First().consFattaNotImp) ? r.First().consFattaNotImp.Trim() : string.Empty;
|
|
cf.consFattaNotImp = nota2;
|
|
cf.consFattaFlagCons = r.First().consFattaFlagCons;
|
|
cf.consFattaDataOra = r.First().consFattaDataOra;
|
|
|
|
o.ConsFatta = cf;
|
|
}
|
|
}
|
|
|
|
return o;
|
|
}
|
|
|
|
[HttpGet("listaGiriTestataByAutistaDataMezzo")]
|
|
public async Task<ActionResult<IEnumerable<GiriConsegna_out>>> listaGiriTestataByAutistaDataMezzo(string autista, DateTime? dataGiro, string mezzo)
|
|
{
|
|
|
|
List<GiriConsegna_out> lst = new List<GiriConsegna_out>();
|
|
_giriCons = _giri_testate_context.Giri;
|
|
var r = await _giriCons.Where(t => t.Piautist != null && t.Piautist.Equals(autista) && t.Pidata != null && t.Pidata == dataGiro && t.Pimezzo != null && t.Pimezzo.Equals(mezzo)).OrderByDescending(t => t.Pidata).ThenBy(t => t.Pisergir).ToListAsync();
|
|
foreach (GiriConsegna d in r)
|
|
{
|
|
GiriConsegna_out o = new GiriConsegna_out();
|
|
|
|
o.Pisergir = d.Pisergir;
|
|
o.Pidata = d.Pidata;
|
|
o.Piautist = d.Piautist;
|
|
o.Pitbancar = d.Pitbancar;
|
|
o.Pitbanrec = d.Pitbanrec;
|
|
o.Pidarecu=d.Pidarecu;
|
|
o.Pidatchi = d.Pidatchi;
|
|
o.Pimezzo = d.Pimezzo;
|
|
|
|
|
|
|
|
lst.Add(o);
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
/// <summary>Salva i dati della consegna</summary>
|
|
[HttpPost]
|
|
[Route("destinazione/salva")]
|
|
public async Task<ActionResult<Consegna_out>> destinazione_salva([FromBody] Consegna model, string token)
|
|
{
|
|
Consegna_out tOut = new Consegna_out();
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
try
|
|
{
|
|
ConsegnaTable ct = fillConsegna(model, token,DateTime.Now);
|
|
//string tecnico = getClaimValueByToken(token, "tccodice");
|
|
if (await checkConsegnaPresente(token, ct) == 0)
|
|
{
|
|
|
|
DateTime dateTime = DateTime.Now;
|
|
ConsegnaTable t = fillConsegna(model, token, dateTime);
|
|
|
|
//Step 1: il seriale è quello della GESAPI_GIRI_SERIALI che ho scritto in validazione
|
|
// lo leggo dalle destinazioni filtrando per il seriale della destinazione. contemporaneamente mi ricavo anche gli altri valori
|
|
//che devo scrivere successivamente
|
|
_destinazioni = _destinazioni_context.Destinazioni;
|
|
var ti = await _destinazioni.Where(t => t.Brserial.Equals(model.Serial)).FirstAsync();
|
|
|
|
string _committente = ti.CodCommittente;
|
|
string _cliFatturazione = ti.CliFatt;
|
|
string _codSede = ti.CodSede;
|
|
string _pisergir = ti.serialeGiro;
|
|
int _seque = ti.Cprownum.Value;
|
|
t.Cca = _committente;
|
|
t.Ccda=_cliFatturazione;
|
|
t.Cprownum = _seque;
|
|
t.Piconseg=_codSede;
|
|
t.Pisergir = _pisergir;
|
|
|
|
//Step 3 : testata la testata va scritta solo per la prima destinazione (cioè la devo scrivere SOLO se non l'ho già scritta)
|
|
|
|
if (await checkTestataPresente(_pisergir) == 0)
|
|
{
|
|
Consegna_m m = new Consegna_m();
|
|
m.Pisergir = t.Pisergir;
|
|
m.Data = dateTime;
|
|
m.Cpccchk = getCpccchk(10);
|
|
using (var transactionM = _consegne_m_context.Database.BeginTransaction())
|
|
{
|
|
await _consegne_m_context.Cons.AddAsync(m);
|
|
await _consegne_m_context.SaveChangesAsync();
|
|
transactionM.Commit();
|
|
}
|
|
}
|
|
|
|
|
|
//step 4 : riga (è sempre e solo una)
|
|
using (var transaction = _consegne_context.Database.BeginTransaction())
|
|
{
|
|
await _consegne_context.Cons.AddAsync(t);
|
|
await _consegne_context.SaveChangesAsync();
|
|
transaction.Commit();
|
|
}
|
|
|
|
tOut = fillConsegna_out(model, token);
|
|
tOut.err_status_code = "200";
|
|
return StatusCode(StatusCodes.Status200OK, tOut);
|
|
}
|
|
else
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "timbratura presente.");
|
|
}
|
|
|
|
//return tOut;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
tOut.err_title = ex.Message;
|
|
tOut.err_detail = errmsg;
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
}
|
|
|
|
/// <summary>Salva i dati della consegna</summary>
|
|
[HttpPost]
|
|
[Route("destinazione/non_effettuata")]
|
|
public async Task<ActionResult<Consegna_out>> destinazione_non_effettuata([FromBody] Consegna model, string token)
|
|
{
|
|
Consegna_out tOut = new Consegna_out();
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
try
|
|
{
|
|
|
|
ConsegnaTable ct = fillConsegna(model, token, DateTime.Now);
|
|
//string tecnico = getClaimValueByToken(token, "tccodice");
|
|
if (await checkConsegnaPresente(token, ct) == 0)
|
|
{
|
|
DateTime dateTime = DateTime.Now;
|
|
ConsegnaTable t = fillConsegnaNonEffettuata(model, token);
|
|
|
|
//Step 1: il seriale è quello della GESAPI_GIRI_SERIALI che ho scritto in validazione
|
|
// lo leggo dalle destinazioni filtrando per il seriale della destinazione. contemporaneamente mi ricavo anche gli altri valori
|
|
//che devo scrivere successivamente
|
|
_destinazioni = _destinazioni_context.Destinazioni;
|
|
var ti = await _destinazioni.Where(t => t.Brserial.Equals(model.Serial)).FirstAsync();
|
|
|
|
string _committente = ti.CodCommittente;
|
|
string _cliFatturazione = ti.CliFatt;
|
|
string _codSede = ti.CodSede;
|
|
string _pisergir = ti.serialeGiro;
|
|
int _seque = ti.Cprownum.Value;
|
|
t.Cca = _committente;
|
|
t.Ccda = _cliFatturazione;
|
|
t.Cprownum = _seque;
|
|
t.Piconseg = _codSede;
|
|
t.Pisergir = _pisergir;
|
|
|
|
|
|
//Step 2 : testata
|
|
if (await checkTestataPresente(_pisergir) == 0)
|
|
{
|
|
|
|
Consegna_m m = new Consegna_m();
|
|
m.Pisergir = t.Pisergir;
|
|
m.Data = dateTime;
|
|
m.Cpccchk = getCpccchk(10);
|
|
using (var transactionM = _consegne_m_context.Database.BeginTransaction())
|
|
{
|
|
await _consegne_m_context.Cons.AddAsync(m);
|
|
await _consegne_m_context.SaveChangesAsync();
|
|
transactionM.Commit();
|
|
}
|
|
}
|
|
|
|
|
|
//step 3 : riga (è sempre e solo una)
|
|
using (var transaction = _consegne_context.Database.BeginTransaction())
|
|
{
|
|
await _consegne_context.Cons.AddAsync(t);
|
|
await _consegne_context.SaveChangesAsync();
|
|
transaction.Commit();
|
|
}
|
|
|
|
tOut = fillConsegna_out(model, token);
|
|
tOut.err_status_code = "200";
|
|
return StatusCode(StatusCodes.Status200OK, tOut);
|
|
}
|
|
else
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "timbratura presente.");
|
|
}
|
|
|
|
//return tOut;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
|
tOut.err_title = ex.Message;
|
|
tOut.err_detail = errmsg;
|
|
tOut.err_status_code = "500";
|
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
|
}
|
|
}
|
|
|
|
private async Task<int> checkConsegnaPresente(string token, ConsegnaTable model)
|
|
{
|
|
int trovati = 0;
|
|
_consegne = _consegne_context.Cons;
|
|
var ti = await _consegne.Where(t => t.Pisergir.Equals(model.Pisergir) && t.Cprownum == model.Cprownum ).ToListAsync();
|
|
if (ti.Any())
|
|
{
|
|
trovati = ti.Count();
|
|
}
|
|
|
|
return trovati;
|
|
}
|
|
private string getClaimValueByToken(string token, string claimName)
|
|
{
|
|
string t = string.Empty;
|
|
|
|
var handler = new JwtSecurityTokenHandler();
|
|
var jwtSecurityToken = handler.ReadJwtToken(token);
|
|
if (jwtSecurityToken != null)
|
|
{
|
|
var id = jwtSecurityToken.Claims.First(claim => claim.Type == claimName).Value;
|
|
t = id;
|
|
}
|
|
return t;
|
|
}
|
|
private string formattaGiro(Giri g)
|
|
{
|
|
string item = string.Empty;
|
|
if (g != null)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
var dateString1 = g.Brdatcar.Value.ToString("dd-MM-yyyy");
|
|
sb.AppendLine("Giro del "+dateString1);
|
|
sb.AppendLine("Assegnato a "+g.Autista);
|
|
sb.AppendLine("Numero consegne " + g.num_dest.ToString());
|
|
item=sb.ToString();
|
|
sb = null;
|
|
}
|
|
|
|
return item;
|
|
}
|
|
private string formattaDestinazione(Destinazioni d)
|
|
{
|
|
string item = string.Empty;
|
|
if (d != null)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
//var dateString1 = d.DataCarico.Value.ToString("dd-MM-yyyy");
|
|
string comm = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
|
|
|
|
sb.Append("<b>Committente</b> " + comm);
|
|
sb.Append("<br> ");
|
|
string sed = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
|
|
sb.Append("<b>Sede Consegna</b> " + sed);
|
|
sb.Append("<br> ");
|
|
string ind = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
|
|
sb.Append("<b>Indirizzo</b> " + ind);
|
|
sb.Append("<br> ");
|
|
|
|
string _casse=d.Casse!=null && d.Casse >0 ? Convert.ToInt16(d.Casse).ToString() : string.Empty;
|
|
if(!string.IsNullOrEmpty(_casse))
|
|
{
|
|
sb.Append("<b>Casse</b> " + _casse + " ");
|
|
}
|
|
string _trasf = d.Trasf != null && d.Trasf > 0 ? Convert.ToInt16( d.Trasf).ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(_trasf))
|
|
{
|
|
sb.Append("<b>Trasf</b> " + _trasf + " ");
|
|
}
|
|
string _colli = d.Colli != null && d.Colli > 0 ? Convert.ToInt16(d.Colli).ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(_colli))
|
|
{
|
|
sb.Append("<b>Colli</b> " + _colli + " ");
|
|
}
|
|
string _num_cons = d.num_cons != null && d.num_cons > 0 ? Convert.ToInt16(d.num_cons).ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(_num_cons))
|
|
{
|
|
sb.Append("<b>Nr.Cons</b> " + _num_cons + " ");
|
|
}
|
|
string _uova = d.Uova != null && d.Uova > 0 ? d.Uova.ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(_uova))
|
|
{
|
|
sb.Append("<b>Uova</b> " + _uova + " ");
|
|
}
|
|
string _cist = d.Cist != null && d.Cist > 0 ? d.Cist.ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(_cist))
|
|
{
|
|
sb.Append("<b>Cist</b> " + _cist + " ");
|
|
}
|
|
string _note=!string.IsNullOrEmpty(d.Note) ? d.Note.Trim() :string.Empty;
|
|
if (!string.IsNullOrEmpty(_note))
|
|
{
|
|
sb.Append("<br> ");
|
|
sb.Append("<b>Note</b> " + _note);
|
|
}
|
|
string _noteCon = !string.IsNullOrEmpty(d.NoteConsegna) ? d.NoteConsegna.Trim() : string.Empty;
|
|
if (!string.IsNullOrEmpty(_noteCon))
|
|
{
|
|
sb.Append("<br> ");
|
|
sb.Append("<b>Note</b> " + _noteCon);
|
|
}
|
|
|
|
item = sb.ToString();
|
|
sb = null;
|
|
}
|
|
|
|
return item;
|
|
}
|
|
private ConsegnaTable fillConsegna(Consegna i, string token, DateTime d)
|
|
{
|
|
ConsegnaTable r = new ConsegnaTable();
|
|
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
|
|
r.Piautist = usr;
|
|
r.Cprownum = i.Cprownum;
|
|
r.Cprownum=i.Cprownum;
|
|
r.Ccddd = i.Ccddd;
|
|
r.cpccchk = getCpccchk(10);
|
|
r.Ccda = i.Ccda;
|
|
r.Dcda = i.Dcda;
|
|
r.Pinotban = i.Pinotban;
|
|
r.Ccadd = i.Ccadd;
|
|
r.Ccda = i.Ccda;
|
|
r.Ccddd=i.Ccddd;
|
|
r.Datdoc= d;
|
|
r.Dcda=i.Dcda;
|
|
r.Descb=i.Descb;
|
|
r.Nbanc = i.Nbanc;
|
|
r.Ndoc = i.Ndoc;
|
|
r.Pibansca = i.Pibansca;
|
|
r.Pinotban = i.Pinotban;
|
|
r.Pinotimp = i.Pinotimp;
|
|
r.Tipob1 = i.Tipob1;
|
|
r.Tipob2 = i.Tipob2;
|
|
r.Tipob =i.Tipob;
|
|
r.Sdoc = i.Sdoc;
|
|
r.Pisergir = i.Serial;
|
|
r.Tcda="S";
|
|
r.Tca = i.Tca;
|
|
r.Cca = i.Cca;
|
|
r.Dca = i.Dca;
|
|
r.Piconseg = i.Piconseg;
|
|
r.Pimezzo = i.Pimezzo;
|
|
r.Piimport= i.Piimport;
|
|
r.Serial=i.Serial;
|
|
r.Pinotcon = i.Pinotcon;
|
|
|
|
|
|
return r;
|
|
}
|
|
private ConsegnaTable fillConsegnaNonEffettuata(Consegna i, string token)
|
|
{
|
|
ConsegnaTable r = new ConsegnaTable();
|
|
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
|
|
r.Piautist = usr;
|
|
r.Cprownum = i.Cprownum;
|
|
r.Ccddd = i.Ccddd;
|
|
r.cpccchk = getCpccchk(10);
|
|
r.Ccda = i.Ccda;
|
|
r.Dcda = i.Dcda;
|
|
r.Pinotban = i.Pinotban;
|
|
r.Ccadd = i.Ccadd;
|
|
r.Ccda = i.Ccda;
|
|
r.Ccddd = i.Ccddd;
|
|
r.Datdoc = DateTime.Now;
|
|
r.Dcda = i.Dcda;
|
|
r.Descb = "Consegna non effetuata";
|
|
r.Nbanc = i.Nbanc;
|
|
r.Ndoc = i.Ndoc;
|
|
r.Pibansca = i.Pibansca;
|
|
r.Pinotban = i.Pinotban;
|
|
r.Pinotimp = i.Pinotimp;
|
|
r.Tipob1 = i.Tipob1;
|
|
r.Tipob2 = i.Tipob2;
|
|
r.Tipob = i.Tipob;
|
|
r.Sdoc = i.Sdoc;
|
|
r.Pisergir = i.Serial;
|
|
//r.Tcda=i.Tcda;
|
|
r.Tcda = "N";
|
|
r.Tca = i.Tca;
|
|
r.Cca = i.Cca;
|
|
r.Dca = i.Dca;
|
|
r.Piconseg = i.Piconseg;
|
|
r.Pimezzo = i.Pimezzo;
|
|
r.Piimport = i.Piimport;
|
|
r.Serial=i.Serial;
|
|
r.Pinotcon=i.Pinotcon;
|
|
|
|
|
|
|
|
return r;
|
|
}
|
|
private Consegna_out fillConsegna_out(Consegna i, string token)
|
|
{
|
|
Consegna_out r = new Consegna_out();
|
|
|
|
string usr = getClaimValueByToken(token, "codice");
|
|
|
|
r.Piautist = usr;
|
|
r.Cprownum = i.Cprownum;
|
|
r.Cprownum = i.Cprownum;
|
|
r.Ccddd = i.Ccddd;
|
|
r.cpccchk = i.cpccchk;
|
|
r.Ccda = i.Ccda;
|
|
r.Dcda = i.Dcda;
|
|
r.Pinotban = i.Pinotban;
|
|
r.Ccadd = i.Ccadd;
|
|
r.Ccda = i.Ccda;
|
|
r.Ccddd = i.Ccddd;
|
|
r.Datdoc = i.Datdoc;
|
|
r.Dcda = i.Dcda;
|
|
r.Descb = i.Descb;
|
|
r.Nbanc = i.Nbanc;
|
|
r.Ndoc = i.Ndoc;
|
|
r.Pibansca = i.Pibansca;
|
|
r.Pinotban = i.Pinotban;
|
|
r.Pinotimp = i.Pinotimp;
|
|
r.Tipob1 = i.Tipob1;
|
|
r.Tipob2 = i.Tipob2;
|
|
r.Tipob = i.Tipob;
|
|
r.Sdoc = i.Sdoc;
|
|
r.Pisergir = i.Serial;
|
|
r.Tcda = i.Tcda;
|
|
r.Tca = i.Tca;
|
|
r.Cca = i.Cca;
|
|
r.Dca = i.Dca;
|
|
r.Piconseg = i.Piconseg;
|
|
r.Pimezzo = i.Pimezzo;
|
|
r.Piimport = i.Piimport;
|
|
r.Pinotcon = i.Pinotcon;
|
|
|
|
|
|
return r;
|
|
}
|
|
private string calcolaNuovoSeriale(string ultSer)
|
|
{
|
|
string newSer = string.Empty;
|
|
|
|
int ser=Convert.ToInt32(ultSer);
|
|
ser++;
|
|
newSer=Convert.ToString(ser);
|
|
|
|
if (ser > 0)
|
|
{
|
|
newSer = newSer.PadLeft(10, '0');
|
|
}
|
|
|
|
return newSer;
|
|
}
|
|
|
|
private static Random random = new Random();
|
|
/// <summary>crea un cpccchk</summary>
|
|
public static string getCpccchk(int length)
|
|
{
|
|
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
|
|
}
|
|
|
|
private async Task<int> checkTestataPresente(string pisergir)
|
|
{
|
|
int trovati = 0;
|
|
_testate = _consegne_m_context.Cons;
|
|
var ti = await _testate.Where(t => t.Pisergir.Equals(pisergir)).ToListAsync();
|
|
if (ti.Any())
|
|
{
|
|
trovati = ti.Count();
|
|
}
|
|
|
|
return trovati;
|
|
}
|
|
}
|
|
|
|
}
|