+ Added migration
+ Added STATIC data into Database (Roles functions and users) + Configuration controller and startupConfig API * Refactor api names
This commit is contained in:
@@ -1,36 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Step.Model.DTOModels;
|
||||
using System.Web.Http;
|
||||
using Step.Database.Controllers;
|
||||
using Step.Model.DTOModels;
|
||||
using static Step.Utils.Constants;
|
||||
using static Step.Config.StartupConfig;
|
||||
|
||||
namespace Step.Controllers.WebApi
|
||||
{
|
||||
|
||||
[RoutePrefix("api/config")]
|
||||
[RoutePrefix("api/configuration")]
|
||||
public class ConfigurationController : ApiController
|
||||
{
|
||||
[Route("functions"), HttpGet]
|
||||
[WebApiAuthorize(FunctionAccess = "test", Action = ACTIONS.READ)]
|
||||
public IHttpActionResult GetFunctionsConfig()
|
||||
{
|
||||
using (FunctionAccessController functionController = new FunctionAccessController())
|
||||
[Route("base"), HttpGet]
|
||||
public IHttpActionResult GetStartupConfiguration()
|
||||
{
|
||||
DTOStartupConfigurationModel startupConfiguration = new DTOStartupConfigurationModel()
|
||||
{
|
||||
var identity = User.Identity as ClaimsIdentity;
|
||||
ProductionConfig = ProductionConfig,
|
||||
AlarmsConfig = AlarmsConfig,
|
||||
ScadaConfig = ScadaConfig,
|
||||
MaintenanceConfig = MaintenanceConfig,
|
||||
ReportConfig = ReportConfig,
|
||||
ToolingConfig = ToolingConfig,
|
||||
UtilitiesConfig = UtilitiesConfig
|
||||
};
|
||||
|
||||
var userRoleLevel = identity.Claims.Where(c => c.Type == ROLE_LEVEL_KEY).SingleOrDefault();
|
||||
|
||||
|
||||
List<DTOFunctionAccessModel> functionsList = functionController.GetFunctionAccess(Convert.ToInt32(userRoleLevel.Value));
|
||||
|
||||
if (functionsList == null)
|
||||
return NotFound();
|
||||
|
||||
return Ok(functionsList);
|
||||
}
|
||||
return Ok(startupConfiguration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user