diff --git a/server/AyaNova/Controllers/DataListController.cs b/server/AyaNova/Controllers/DataListController.cs index 47630c4b..eaab3222 100644 --- a/server/AyaNova/Controllers/DataListController.cs +++ b/server/AyaNova/Controllers/DataListController.cs @@ -73,8 +73,6 @@ namespace AyaNova.Api.Controllers } } - - /// /// List of all DataList keys available /// @@ -92,5 +90,30 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(DataListFactory.GetListOfAllDataListKeyNames(), true)); } + + /// + /// List of all fields for data list key specified + /// + /// Required roles: Any + /// + /// List of DataListFieldDefinition + [HttpGet("ListFields")] + public ActionResult GetDataListFields([FromQuery] string DataListKey) + { + if (!serverState.IsOpen) + { + return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); + } + + var DataList = DataListFactory.GetAyaDataList(DataListKey); + //was the name not found as a list? + if (DataList == null) + { + return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "DataListKey", $"DataList \"{DataListKey}\" specified does not exist")); + } + + return Ok(ApiOkResponse.Response(DataList.FieldDefinitions, true)); + } + }//eoc }//ens \ No newline at end of file diff --git a/server/AyaNova/DataList/AyaDataListFieldDefinition.cs b/server/AyaNova/DataList/AyaDataListFieldDefinition.cs index 4bb6bd4b..d006d790 100644 --- a/server/AyaNova/DataList/AyaDataListFieldDefinition.cs +++ b/server/AyaNova/DataList/AyaDataListFieldDefinition.cs @@ -1,4 +1,6 @@ using AyaNova.Biz; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; namespace AyaNova.DataList { @@ -31,8 +33,11 @@ namespace AyaNova.DataList //CLIENT / SERVER - client display and to indicate what object to open , Server for formatting return object public int AyaObjectType { get; set; } - //SERVER - for building sql queries + //SERVER - for building sql queries + //don't return these properties when api user fetches field list definitions in DataListController + [JsonIgnore] public string SqlIdColumnName { get; set; } + [JsonIgnore] public string SqlValueColumnName { get; set; }