This commit is contained in:
123
server/AyaNova/Controllers/AyaEnumPickListController.cs
Normal file
123
server/AyaNova/Controllers/AyaEnumPickListController.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
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 AyaEnumPickListController : 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 AyaEnumPickListController(AyContext dbcontext, ILogger<AyaTypeController> logger, ApiServerState apiServerState)
|
||||
{
|
||||
ct = dbcontext;
|
||||
log = logger;
|
||||
serverState = apiServerState;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get name value localized display value list of AyaNova enumerated types for list specified
|
||||
///
|
||||
/// Required roles: Any
|
||||
/// </summary>
|
||||
/// <param name="enumName"></param>
|
||||
/// <returns>List</returns>
|
||||
[HttpGet("{enumname}")]
|
||||
public ActionResult GetPickList([FromRoute]string enumName)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
long LocaleId = UserLocaleIdFromContext.Id(HttpContext.Items);
|
||||
List<string> LocaleKeysToFetch = new List<string>();
|
||||
|
||||
List<NameIdItem> ReturnList = new List<NameIdItem>();
|
||||
|
||||
switch (enumName)
|
||||
{
|
||||
case "usertypes":
|
||||
LocaleKeysToFetch.Add("UserTypesAdministrator");
|
||||
LocaleKeysToFetch.Add("UserTypesSchedulable");
|
||||
LocaleKeysToFetch.Add("UserTypesNonSchedulable");
|
||||
LocaleKeysToFetch.Add("UserTypesClient");
|
||||
LocaleKeysToFetch.Add("UserTypesHeadOffice");
|
||||
LocaleKeysToFetch.Add("UserTypesSubContractor");
|
||||
var LT = LocaleBiz.GetSubsetStatic(LocaleKeysToFetch, LocaleId).Result;
|
||||
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypesAdministrator"], Id = (long)UserType.Administrator });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypesSchedulable"], Id = (long)UserType.Schedulable });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypesNonSchedulable"], Id = (long)UserType.NonSchedulable });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypesClient"], Id = (long)UserType.Client });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypesHeadOffice"], Id = (long)UserType.HeadOffice });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypesSubContractor"], Id = (long)UserType.Subcontractor });
|
||||
break;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return Ok(new ApiOkResponse(ReturnList));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get all possible enumerated values picklists
|
||||
///
|
||||
/// Required roles: Any
|
||||
/// </summary>
|
||||
/// <returns>List</returns>
|
||||
[HttpGet()]
|
||||
public ActionResult GetTypesList()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
Dictionary<string, string> ret = new Dictionary<string, string>();
|
||||
|
||||
ret.Add("usertypes", "AyaNova user account types");
|
||||
ret.Add("authorizationroles", "AyaNova user account role types");
|
||||
ret.Add("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these");
|
||||
|
||||
return Ok(new ApiOkResponse(ret));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
}//ens
|
||||
@@ -1442,5 +1442,6 @@
|
||||
"WidgetNotes":"Notizen",
|
||||
"RowsPerPage":"Zeilen pro Seite",
|
||||
"Tags":"Kategorien",
|
||||
"ID":"ID"
|
||||
"ID":"ID",
|
||||
"UserTypesSubContractor": "Subunternehmer"
|
||||
}
|
||||
|
||||
@@ -1441,7 +1441,8 @@
|
||||
"WidgetNotes":"Notes",
|
||||
"RowsPerPage":"Rows per page",
|
||||
"Tags":"Tags",
|
||||
"ID":"ID"
|
||||
"ID":"ID",
|
||||
"UserTypesSubContractor": "SubContractor user"
|
||||
|
||||
|
||||
}
|
||||
@@ -1442,5 +1442,6 @@
|
||||
"WidgetNotes":"Notas",
|
||||
"RowsPerPage":"Filas por página",
|
||||
"Tags":"Etiquetas",
|
||||
"ID":"ID"
|
||||
"ID":"ID",
|
||||
"UserTypesSubContractor": "Subcontratista"
|
||||
}
|
||||
@@ -1441,5 +1441,6 @@
|
||||
"WidgetNotes":"Notes",
|
||||
"RowsPerPage":"Lignes par page",
|
||||
"Tags":"Balises",
|
||||
"ID":"ID"
|
||||
"ID":"ID",
|
||||
"UserTypesSubContractor": "Sous-traitant"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user