Files
raven/server/AyaNova/Controllers/AuthorizationRolesController.cs
2020-01-28 19:43:22 +00:00

89 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
using AyaNova.Models;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
namespace AyaNova.Api.Controllers
{
/// <summary>
/// Enum pick list controller
/// </summary>
[ApiController]
[ApiVersion("8.0")]
[Route("api/v{version:apiVersion}/[controller]")]
[Produces("application/json")]
[Authorize]
public class AuthorizationRolesController : ControllerBase
{
private readonly AyContext ct;
private readonly ILogger<AyaTypeController> log;
private readonly ApiServerState serverState;
/// <summary>
/// ctor
/// </summary>
/// <param name="dbcontext"></param>
/// <param name="logger"></param>
/// <param name="apiServerState"></param>
public AuthorizationRolesController(AyContext dbcontext, ILogger<AyaTypeController> logger, ApiServerState apiServerState)
{
ct = dbcontext;
log = logger;
serverState = apiServerState;
}
/// <summary>
/// Get roles
/// </summary>
/// <returns>Dictionary list of AyaNova object types and their authorization role rights in AyaNova</returns>
[HttpGet("list")]
public ActionResult GetRoles()
{
if (!serverState.IsOpen)
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
return Ok(ApiOkResponse.Response(BizRoles.roles, true));
}
// /// <summary>
// /// Get all possible enumerated values picklist key names
// /// </summary>
// /// <returns>List of AyaNova enumerated type list key names that can be fetched from the AyaEnumPickList/GetPickListRoute</returns>
// [HttpGet("listkeys")]
// public ActionResult GetTypesList()
// {
// if (!serverState.IsOpen)
// {
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// }
// List<KeyValuePair<string, string>> ret = new List<KeyValuePair<string, string>>();
// ret.Add(new KeyValuePair<string, string>("usertypes", "AyaNova user account types"));
// ret.Add(new KeyValuePair<string, string>("authorizationroles", "AyaNova user account role types"));
// ret.Add(new KeyValuePair<string, string>("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these"));
// ret.Add(new KeyValuePair<string, string>("datatypes", "Types of data used in AyaNova for display and formatting UI purposes"));
// return Ok(ApiOkResponse.Response(ret, true));
// }
}//eoc
}//ens