This commit is contained in:
88
server/AyaNova/Controllers/TagPickListController.cs
Normal file
88
server/AyaNova/Controllers/TagPickListController.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum pick list controller
|
||||
/// </summary>
|
||||
[ApiVersion("8.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
public class TagPickListController : Controller
|
||||
{
|
||||
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 TagPickListController(AyContext dbcontext, ILogger<AyaTypeController> logger, ApiServerState apiServerState)
|
||||
{
|
||||
ct = dbcontext;
|
||||
log = logger;
|
||||
serverState = apiServerState;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get tag picklist
|
||||
///
|
||||
/// Required roles: Any
|
||||
/// </summary>
|
||||
/// <param name="query">The query to filter the returned list by</param>
|
||||
/// <returns>List</returns>
|
||||
[HttpGet("list/{query}")]
|
||||
public ActionResult GetPickList([FromRoute]string query)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
return Ok(new ApiOkResponse(TagUtil.PickListFiltered(ct,query)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Get all possible enumerated values picklist key names
|
||||
// ///
|
||||
// /// Required roles: Any
|
||||
// /// </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"));
|
||||
|
||||
// return Ok(new ApiOkResponse(ret));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
}//ens
|
||||
Reference in New Issue
Block a user