This commit is contained in:
2020-01-21 23:33:24 +00:00
parent aac48abf0c
commit 5ebf1d9eec
3 changed files with 25 additions and 51 deletions

View File

@@ -7,18 +7,29 @@ using Microsoft.AspNetCore.Mvc;
using AyaNova.Models;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using EnumsNET;
namespace AyaNova.DataList
{
internal static class DataListFetcher
{
internal static async Task<ApiPagedResponse> GetResponse(string DataListKey, AyContext ct, IUrlHelper Url,
string routeName, ListOptions listOptions, long UserId)
string routeName, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles)
{
// var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
var DataList = DataListFactory.GetAyaDataList(DataListKey);
//was the name not found as a list?
if (DataList == null)
{
throw new System.ArgumentOutOfRangeException($"DataList \"{DataListKey}\" specified does not exist");
}
//check rights
if (!UserRoles.HasAnyFlags(DataList.AllowedRoles))
{
throw new System.NotSupportedException("User roles insufficient for this datalist");
}
//TODO: FETCH DATALISTTEMPLATE HERE OR USE DEFAULT IF FAULTY OR NOT FOUND
var JSONDataListTemplate = DataList.DefaultDataListDisplayTemplate;