Predisposti controller e data service
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user