5bd278fa69
* Added NC handler class * Fixed threads * Added threads: AXES, ALARMS, GENERIC INFO + API * Refactoring
48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Step.Model.DatabaseModels;
|
|
using Step.Model.DTOModels;
|
|
|
|
namespace Step.Database.Controllers
|
|
{
|
|
public class FunctionAccessController : IDisposable
|
|
{
|
|
private DatabaseContext dbCtx;
|
|
|
|
public FunctionAccessController()
|
|
{
|
|
// Initialize database context
|
|
dbCtx = new DatabaseContext();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
// Clear database context
|
|
dbCtx.Dispose();
|
|
}
|
|
|
|
public FunctionAccessModel FindEnabledFunctionByName(string functionName)
|
|
{
|
|
return dbCtx
|
|
.FunctionsAccess
|
|
.Where(x => x.Name == functionName && x.Enabled == true)
|
|
.FirstOrDefault();
|
|
}
|
|
|
|
public List<DTOFunctionAccessModel> GetFunctionAccess()
|
|
{
|
|
return dbCtx
|
|
.FunctionsAccess
|
|
.Select(f => new DTOFunctionAccessModel()
|
|
{
|
|
Id = f.FunctionAccessId,
|
|
Name = f.Name,
|
|
Area = f.Area,
|
|
Enabled = f.Enabled
|
|
})
|
|
.ToList() ;
|
|
}
|
|
}
|
|
}
|