55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WebDoorCreator.Data.DbModels;
|
|
|
|
namespace WebDoorCreator.Data.Controllers
|
|
{
|
|
public class WebDoorCreatorController : IDisposable
|
|
{
|
|
private static IConfiguration _configuration;
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
public WebDoorCreatorController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
public void Dispose()
|
|
{
|
|
// Clear database context
|
|
//Log.Info("Dispose di GWMSController");
|
|
}
|
|
/// <summary>
|
|
/// Recupera l'elenco Company (ALL)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<CompanyModel> CompanyAll()
|
|
{
|
|
// init dati necessari
|
|
List<CompanyModel> dbResult = new List<CompanyModel>();
|
|
// cerco su DB recuperando set di dati....
|
|
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
|
{
|
|
try
|
|
{
|
|
// recupero intero set...
|
|
dbResult = localDbCtx
|
|
.DbSetCompany
|
|
.OrderBy(x => x.CompanyName)
|
|
.ToList();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Log.Error($"Error in CompanyAll:{Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
|
|
}
|
|
}
|