47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using NLog;
|
|
using SMGen.Data.DbModels;
|
|
|
|
namespace SMGen.Data.Controllers
|
|
{
|
|
public class SMGenController : IDisposable
|
|
{
|
|
private static IConfiguration _configuration;
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
public SMGenController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public void Dispose()
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Aggiunta in bulk delle transizioni/ingressi
|
|
/// </summary>
|
|
/// <param name="newTIRecs"></param>
|
|
/// <returns></returns>
|
|
public async Task<bool> TranInInsert(List<TransizioneIngressiTempModel> newTIRecs)
|
|
{
|
|
bool fatto = false;
|
|
using (SMGDataContext localDbCtx = new SMGDataContext(_configuration))
|
|
{
|
|
try
|
|
{
|
|
localDbCtx
|
|
.DbSetTranIngTemp
|
|
.AddRange(newTIRecs);
|
|
await localDbCtx.SaveChangesAsync();
|
|
fatto = true;
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Log.Error($"Eccezione durante TranInInsert: {Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
return fatto;
|
|
}
|
|
}
|
|
} |