campi destinazione (colli, uova, ecc) sequenza e varie
This commit is contained in:
parent
1b2ab58488
commit
194a3db2e8
@ -170,6 +170,7 @@ namespace ApiSoftway.Controllers
|
||||
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);
|
||||
@ -428,7 +429,7 @@ namespace ApiSoftway.Controllers
|
||||
|
||||
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).ToListAsync();
|
||||
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();
|
||||
@ -472,6 +473,7 @@ namespace ApiSoftway.Controllers
|
||||
o.Uova=d.Uova;
|
||||
o.Cist=d.Cist;
|
||||
o.Note=d.Note;
|
||||
o.Seq = d.Seq;
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(d.consFattaSerial))
|
||||
|
||||
93
Controllers/ModificaGiroController.cs
Normal file
93
Controllers/ModificaGiroController.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using ApiSoftway.Models;
|
||||
using ApiSoftway.Models.Gesa_DbContext;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace ApiSoftway.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ModificaGiroController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<LoginController> _logger;
|
||||
private readonly IConfiguration? _configuration;
|
||||
private readonly GESA_MODGIR_DbContext _modgiri_context;
|
||||
private DbSet<Modgir>? _modgir;
|
||||
public ModificaGiroController(ILogger<LoginController> logger, IConfiguration? configuration, GESA_MODGIR_DbContext modgiri_context)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_modgiri_context= modgiri_context;
|
||||
}
|
||||
/// <summary>Salva i dati della consegna</summary>
|
||||
[HttpPost]
|
||||
[Route("addModgir")]
|
||||
public async Task<ActionResult<GiriConsegna_out>> addModgir(Modgir model)
|
||||
{
|
||||
Modgir_out tOut = new Modgir_out();
|
||||
//string usr = getClaimValueByToken(token, "codice");
|
||||
try
|
||||
{
|
||||
//step 1 : calcolo il nuovo seriale
|
||||
_modgir = _modgiri_context.Mod;
|
||||
var ser = await _modgir.Take(1).OrderByDescending(t => t.Piprogre).ToListAsync();
|
||||
string ultSer = string.Empty;
|
||||
if (ser!=null && ser.Count()>0)
|
||||
{
|
||||
ultSer = ser.First().Piprogre;
|
||||
}
|
||||
|
||||
string newSer = calcolaNuovoSeriale(ultSer);
|
||||
|
||||
//step 2 : inserisco in PIGIRCON
|
||||
Modgir gc = new Modgir();
|
||||
|
||||
gc.Piprogre = newSer;
|
||||
gc.Piserial = model.Piserial;
|
||||
gc.Pidata = model.Pidata;
|
||||
gc.Picommit = model.Picommit;
|
||||
gc.Pidesdiv = model.Pidesdiv;
|
||||
gc.Pitarga = model.Pitarga;
|
||||
gc.Piautist = model.Piautist;
|
||||
gc.Pitiprec = model.Pitiprec;
|
||||
|
||||
using (var transactionGiri = _modgiri_context.Database.BeginTransaction())
|
||||
{
|
||||
await _modgiri_context.Mod.AddAsync(gc);
|
||||
await _modgiri_context.SaveChangesAsync();
|
||||
transactionGiri.Commit();
|
||||
}
|
||||
|
||||
var giro = await _modgiri_context.Mod.Where(t => t.Piprogre.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);
|
||||
}
|
||||
}
|
||||
private string calcolaNuovoSeriale(string ultSer)
|
||||
{
|
||||
string newSer = "0000000000";
|
||||
|
||||
if(!string.IsNullOrEmpty(ultSer))
|
||||
{
|
||||
int ser = Convert.ToInt32(ultSer);
|
||||
ser++;
|
||||
newSer = Convert.ToString(ser);
|
||||
|
||||
if (ser > 0)
|
||||
{
|
||||
newSer = newSer.PadLeft(10, '0');
|
||||
}
|
||||
}
|
||||
return newSer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,6 +50,7 @@ namespace ApiSoftway.Models
|
||||
public int? Uova { get; set; }
|
||||
public int? Cist { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public int? Seq { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ namespace ApiSoftway.Models
|
||||
public int? Uova { get; set; }
|
||||
public int? Cist { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public int? Seq { get; set; }
|
||||
}
|
||||
public class ConsegnaFatta
|
||||
{
|
||||
|
||||
23
Models/Gesa_DbContext/GESA_MODGIR_DbContext.cs
Normal file
23
Models/Gesa_DbContext/GESA_MODGIR_DbContext.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ApiSoftway.Models.Gesa_DbContext
|
||||
{
|
||||
public class GESA_MODGIR_DbContext : DbContext
|
||||
{
|
||||
public DbSet<Modgir>? Mod { get; set; }
|
||||
|
||||
/// <summary></summary>
|
||||
public GESA_MODGIR_DbContext(DbContextOptions<GESA_MODGIR_DbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary></summary>
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Modgir>().ToTable("GESAPIMODGIR");
|
||||
modelBuilder.Entity<Modgir>().HasKey(table => new {
|
||||
table.Piprogre
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,5 +19,7 @@ namespace ApiSoftway.Models
|
||||
|
||||
public DateTime? Pidatchi { get; set; }
|
||||
|
||||
public string? Pimezzo { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ namespace ApiSoftway.Models
|
||||
[Keyless]
|
||||
public class GiriConsegnaDaCreare
|
||||
{
|
||||
public string? CodAutomezzo { get; set; }
|
||||
public string? CodMezzo { get; set; }
|
||||
public string? CodAutista { get; set; }
|
||||
public string? Autista { get; set; }
|
||||
public string? Automezzo { get; set; }
|
||||
|
||||
@ -22,5 +22,12 @@ namespace ApiSoftway.Models
|
||||
public string? CodMezzo { get; set; }
|
||||
public string? Automezzo { get; set; }
|
||||
|
||||
|
||||
public int? parzialeBanRec { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||
public decimal? parzialeImpRec { get; set; }
|
||||
|
||||
public string? NoteChiusura { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
18
Models/Modgir.cs
Normal file
18
Models/Modgir.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApiSoftway.Models
|
||||
{
|
||||
public class Modgir
|
||||
{
|
||||
[Key]
|
||||
public string? Piprogre { get; set; }
|
||||
public string? Piserial { get; set; }
|
||||
public DateTime? Pidata { get; set; }
|
||||
public string? Picommit { get; set; }
|
||||
public string? Pidesdiv { get; set; }
|
||||
public string? Pitarga { get; set; }
|
||||
public string? Piautist { get; set; }
|
||||
public string? Pitiprec { get; set; }
|
||||
public string? Pirigele { get; set; }
|
||||
}
|
||||
}
|
||||
25
Models/Modgir_out.cs
Normal file
25
Models/Modgir_out.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ApiSoftway.Models
|
||||
{
|
||||
[Keyless]
|
||||
public class Modgir_out
|
||||
{
|
||||
public string? Piprogre { get; set; }
|
||||
public string? Piserial { get; set; }
|
||||
public DateTime? Pidata { get; set; }
|
||||
public string? Picommit { get; set; }
|
||||
public string? Pidesdiv { get; set; }
|
||||
public string? Pitarga { get; set; }
|
||||
public string? Piautist { get; set; }
|
||||
public string? Pitiprec { get; set; }
|
||||
public string? Pirigele { get; set; }
|
||||
|
||||
/// <summary>errore titolo</summary>
|
||||
public string? err_title { get; set; }
|
||||
/// <summary>errore dettaglio</summary>
|
||||
public string? err_detail { get; set; }
|
||||
/// <summary>errore status code (200, 500)</summary>
|
||||
public string? err_status_code { get; set; }
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,9 @@ builder.Services.AddDbContext<GESA_SBR_ORD_DbContext>(options => options.UseSqlS
|
||||
builder.Services.AddDbContext<GESA_GIRICONSEGNEDACREARE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||
));
|
||||
builder.Services.AddDbContext<GESA_MODGIR_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||
));
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user