Michele: metodi crud per MagazziniVT e messo controllo in Login (magazzini) per magazziniVT
This commit is contained in:
parent
a798cbe061
commit
9bb354e107
@ -464,6 +464,10 @@ namespace ApiPolo.Controllers
|
|||||||
private readonly VT_MAG_NEW_DbContext _VT_MagNew;
|
private readonly VT_MAG_NEW_DbContext _VT_MagNew;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region VT-MAGAZZINI
|
||||||
|
private readonly VT_MAGAZZINI_DbContext _VT_Magazzini;
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Commesse desc
|
#region Commesse desc
|
||||||
private readonly SIET_COMMESSE_DESC_DbContext _Siet_commDesc;
|
private readonly SIET_COMMESSE_DESC_DbContext _Siet_commDesc;
|
||||||
private readonly MARRO_COMMESSE_TABLE_DbContext _Marro_commDesc;
|
private readonly MARRO_COMMESSE_TABLE_DbContext _Marro_commDesc;
|
||||||
@ -517,6 +521,7 @@ namespace ApiPolo.Controllers
|
|||||||
private DbSet<Rapp_New_View>? _rapp_new_view;
|
private DbSet<Rapp_New_View>? _rapp_new_view;
|
||||||
private DbSet<Articoli>? _articoliTable;
|
private DbSet<Articoli>? _articoliTable;
|
||||||
private DbSet<Vt_Mag_New>? _magNewVT;
|
private DbSet<Vt_Mag_New>? _magNewVT;
|
||||||
|
private DbSet<MagazziniVT>? _magazziniVT;
|
||||||
|
|
||||||
private DbSet<CommessaDesc>? _commDesc;
|
private DbSet<CommessaDesc>? _commDesc;
|
||||||
private DbSet<CommessaDescSiet>? _commDescSiet;
|
private DbSet<CommessaDescSiet>? _commDescSiet;
|
||||||
@ -887,7 +892,8 @@ namespace ApiPolo.Controllers
|
|||||||
VT_STO_RAPP_DbContext VT_StoRapp,
|
VT_STO_RAPP_DbContext VT_StoRapp,
|
||||||
VT_TIMBRATURE_DbContext VT_timbr,
|
VT_TIMBRATURE_DbContext VT_timbr,
|
||||||
VT_ARTICOLI_TABLE_DbContext VT_artTable,
|
VT_ARTICOLI_TABLE_DbContext VT_artTable,
|
||||||
VT_MAG_NEW_DbContext VT_MagNew
|
VT_MAG_NEW_DbContext VT_MagNew,
|
||||||
|
VT_MAGAZZINI_DbContext VT_Magazzini
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -1236,6 +1242,7 @@ namespace ApiPolo.Controllers
|
|||||||
_VT_StoRapp = VT_StoRapp;
|
_VT_StoRapp = VT_StoRapp;
|
||||||
_VT_articoliTable = VT_artTable;
|
_VT_articoliTable = VT_artTable;
|
||||||
_VT_MagNew = VT_MagNew;
|
_VT_MagNew = VT_MagNew;
|
||||||
|
_VT_Magazzini = VT_Magazzini;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Commesse desc
|
#region Commesse desc
|
||||||
@ -3861,8 +3868,7 @@ namespace ApiPolo.Controllers
|
|||||||
[HttpGet("magazzini")]
|
[HttpGet("magazzini")]
|
||||||
public async Task<ActionResult<IEnumerable<Magazzini>>> magazzini(string token)
|
public async Task<ActionResult<IEnumerable<Magazzini>>> magazzini(string token)
|
||||||
{
|
{
|
||||||
|
List<Magazzini> lst= new List<Magazzini>();
|
||||||
List < Magazzini > lst= new List<Magazzini>();
|
|
||||||
string ten = getClaimValueByToken(token, "tenant");
|
string ten = getClaimValueByToken(token, "tenant");
|
||||||
string ten2 = getClaimValueByToken(token, "tenant2");
|
string ten2 = getClaimValueByToken(token, "tenant2");
|
||||||
string tenAdhoc = getClaimValueByToken(token, "tenantConfigurazioni");
|
string tenAdhoc = getClaimValueByToken(token, "tenantConfigurazioni");
|
||||||
@ -3874,6 +3880,19 @@ namespace ApiPolo.Controllers
|
|||||||
|
|
||||||
if (ten.Equals(Clienti.VT))
|
if (ten.Equals(Clienti.VT))
|
||||||
{
|
{
|
||||||
|
_magazziniVT = _VT_Magazzini.Magazzini;
|
||||||
|
|
||||||
|
List<MagazziniVT> magaVTList = new List<MagazziniVT>();
|
||||||
|
magaVTList = await _magazziniVT.Where(x => x.Azienda.Equals(ten2)).ToListAsync();
|
||||||
|
|
||||||
|
foreach (var magVT in magaVTList)
|
||||||
|
{
|
||||||
|
Magazzini maga = new Magazzini();
|
||||||
|
maga.mgcodmag = magVT.Mgcodmag.TrimEnd();
|
||||||
|
maga.mgdesmag = magVT.Mgdesmag.TrimEnd();
|
||||||
|
|
||||||
|
lst.Add(maga);
|
||||||
|
}
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -6350,7 +6369,6 @@ namespace ApiPolo.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Clienti.VT:
|
case Clienti.VT:
|
||||||
using (var transactionVT = _VT_rapptable.Database.BeginTransaction())
|
using (var transactionVT = _VT_rapptable.Database.BeginTransaction())
|
||||||
{
|
{
|
||||||
@ -8832,15 +8850,14 @@ namespace ApiPolo.Controllers
|
|||||||
{
|
{
|
||||||
Saldiart saldo = new Saldiart();
|
Saldiart saldo = new Saldiart();
|
||||||
|
|
||||||
saldo.slcodice = a.SlCodice;
|
saldo.slcodice = a.SlCodice.TrimEnd();
|
||||||
saldo.slcodice = a.SlCodice;
|
saldo.ardesart = a.ArDesArt.TrimEnd();
|
||||||
saldo.ardesart = a.ArDesArt;
|
saldo.slcodmag = a.SlCodMag.TrimEnd();
|
||||||
saldo.slcodmag = a.SlCodMag;
|
|
||||||
saldo.slqtaper = a.SlQtAper;
|
saldo.slqtaper = a.SlQtAper;
|
||||||
saldo.amcodice = a.AmCodice;
|
saldo.amcodice = a.AmCodice.TrimEnd();
|
||||||
saldo.locodice = a.LoCodice;
|
saldo.locodice = a.LoCodice.TrimEnd();
|
||||||
saldo.licodlis = a.LiCodLis;
|
saldo.licodlis = a.LiCodLis.TrimEnd();
|
||||||
saldo.licodart = a.LiCodArt;
|
saldo.licodart = a.LiCodArt.TrimEnd();
|
||||||
saldo.lidatatt = a.LiDatAtt;
|
saldo.lidatatt = a.LiDatAtt;
|
||||||
saldo.liquanti = a.LiQuanti;
|
saldo.liquanti = a.LiQuanti;
|
||||||
saldo.liprezzo = a.LiPrezzo;
|
saldo.liprezzo = a.LiPrezzo;
|
||||||
@ -8848,10 +8865,10 @@ namespace ApiPolo.Controllers
|
|||||||
saldo.liscont2 = a.LiScont2;
|
saldo.liscont2 = a.LiScont2;
|
||||||
saldo.liscont3 = a.LiScont3;
|
saldo.liscont3 = a.LiScont3;
|
||||||
saldo.liscont4 = a.LiScont4;
|
saldo.liscont4 = a.LiScont4;
|
||||||
saldo.gest_matr = a.Gest_Matr;
|
saldo.gest_matr = a.Gest_Matr.TrimEnd();
|
||||||
saldo.gest_lotti = a.Gest_Lotti;
|
saldo.gest_lotti = a.Gest_Lotti.TrimEnd();
|
||||||
saldo.desc_sup = a.Desc_sup;
|
saldo.desc_sup = a.Desc_sup.TrimEnd();
|
||||||
|
|
||||||
listaSaldiArt.Add(saldo);
|
listaSaldiArt.Add(saldo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15793,6 +15810,110 @@ namespace ApiPolo.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>VIRTUAL TASK: lista Magazzini per azienda</summary>
|
||||||
|
[HttpGet("magazziniVTList")]
|
||||||
|
public async Task<ActionResult<IEnumerable<MagazziniVT>>> MagazziniVTList(string token)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<MagazziniVT> maglist = new List<MagazziniVT>();
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
string tecnico = getClaimValueByToken(token, "tccodice");
|
||||||
|
_magazziniVT = _VT_Magazzini.Magazzini;
|
||||||
|
|
||||||
|
var magazziniList = await _magazziniVT.Where(x => x.Azienda.Equals(ten)).ToListAsync();
|
||||||
|
foreach (MagazziniVT magaz in magazziniList)
|
||||||
|
{
|
||||||
|
maglist.Add(magaz);
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, maglist);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string err = "Errore: " + ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, err); ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary> VIRTUAL TASK : crea nuovo magazzino return: ActionResult</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("magazziniVT/add")]
|
||||||
|
public async Task<ActionResult<MagazziniVT>> addMagazzinoVT([FromBody] MagazziniVT model, string token)
|
||||||
|
{
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
model.Azienda = ten;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = _VT_Magazzini.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
await _VT_Magazzini.Magazzini.AddAsync(model);
|
||||||
|
await _VT_Magazzini.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, errmsg); ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary> VIRTUAL TASK : modifica magazzino return: ActionResult</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("magazziniVT/mod")]
|
||||||
|
public async Task<ActionResult<MagazziniVT>> modMagazzino([FromBody] MagazziniVT model, string token)
|
||||||
|
{
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
model.Azienda = ten;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = _VT_Magazzini.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
_VT_Magazzini.Entry(model).State = EntityState.Modified;
|
||||||
|
await _VT_Magazzini.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>VIRTUAL TASK: cancella un magazzino return:ActionResult</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("magazziniVT/del")]
|
||||||
|
public async Task<ActionResult<MagazziniVT>> delMagazzino(string magCodice, string token)
|
||||||
|
{
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
_magazziniVT = _VT_Magazzini.Magazzini;
|
||||||
|
var art = await _magazziniVT.Where(a => a.Mgcodmag.Equals(magCodice) && a.Azienda.Equals(ten)).ToListAsync();
|
||||||
|
|
||||||
|
MagazziniVT model = art.First();
|
||||||
|
model.DataObso = DateTime.Now;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = _VT_Magazzini.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
_VT_Magazzini.Entry(model).State = EntityState.Modified;
|
||||||
|
await _VT_Magazzini.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Logging
|
#region Logging
|
||||||
|
|||||||
29
ApiPolo/Models/MagazziniVT.cs
Normal file
29
ApiPolo/Models/MagazziniVT.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models
|
||||||
|
{
|
||||||
|
public class MagazziniVT
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Azienda
|
||||||
|
/// </summary>
|
||||||
|
[Key]
|
||||||
|
public string? Azienda { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// codice magazzino
|
||||||
|
/// </summary>
|
||||||
|
[Key]
|
||||||
|
public string? Mgcodmag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// descrizione
|
||||||
|
/// </summary>
|
||||||
|
public string? Mgdesmag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// descrizione
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? DataObso { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
25
ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs
Normal file
25
ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models.VT_dbcontext
|
||||||
|
{
|
||||||
|
public class VT_MAGAZZINI_DbContext :DbContext
|
||||||
|
{
|
||||||
|
public DbSet<MagazziniVT> Magazzini { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public VT_MAGAZZINI_DbContext(DbContextOptions<VT_MAGAZZINI_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<MagazziniVT>().ToTable("MAGAZZINI");
|
||||||
|
modelBuilder.Entity<MagazziniVT>().HasKey(Table => new
|
||||||
|
{
|
||||||
|
Table.Azienda,
|
||||||
|
Table.Mgcodmag
|
||||||
|
}); // Definizione della chiave primaria composta
|
||||||
|
//base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -758,6 +758,9 @@ namespace ApiPolo
|
|||||||
services.AddDbContext<VT_SALDIART_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
services.AddDbContext<VT_SALDIART_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
||||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
));
|
));
|
||||||
|
services.AddDbContext<VT_MAGAZZINI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user