60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Configuration;
|
|
using NLog;
|
|
|
|
namespace BlaServApp.Data.Controllers
|
|
{
|
|
public class BlaServAppController : IDisposable
|
|
{
|
|
#region Private Fields
|
|
|
|
private static IConfiguration _configuration;
|
|
private static BlaServAppContext dbCtx;
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Public Constructors
|
|
|
|
public BlaServAppController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
dbCtx = new BlaServAppContext(configuration);
|
|
Log.Info("Avviata classe BlaServAppController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
// Clear database context
|
|
dbCtx.Dispose();
|
|
}
|
|
|
|
public List<DatabaseModels.Articoli> getArticoli()
|
|
{
|
|
var dbResult = dbCtx
|
|
.DbSetArticoli
|
|
.ToList();
|
|
|
|
return dbResult;
|
|
}
|
|
|
|
public List<DatabaseModels.Config> getConfig()
|
|
{
|
|
var dbResult = dbCtx
|
|
.DbSetConfig
|
|
.ToList();
|
|
|
|
return dbResult;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |