This commit is contained in:
2020-02-18 16:23:25 +00:00
parent 6497ce3476
commit f0e2de82ea
2 changed files with 48 additions and 8 deletions

View File

@@ -25,16 +25,15 @@ namespace AyaNova.Biz
BizType = AyaType.DataListView;
}
internal static DataListViewBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
internal static DataListViewBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
{
return new DataListViewBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
if (httpContext != null)
return new DataListViewBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
else
return new DataListViewBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull);
}
// //Version for internal use
// internal static DataListFilterBiz GetBizInternal(AyContext ct)
// {
// return new DataListFilterBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull);
// }
////////////////////////////////////////////////////////////////////////////////////////////////
//EXISTS
@@ -260,7 +259,7 @@ namespace AyaNova.Biz
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListView", $"ListView array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified");
}
}
}
//This is the old filter validation code but at this point only going to validate that the fields are present and valid as the bare minimum

View File

@@ -136,6 +136,47 @@ namespace AyaNova.Util
}
}
//Create a couple of DataListView's for development and testing
{
var dlv = new DataListView()
{
Name = "Name starts with generic",
UserId = 1,
ListKey = "TestWidgetDataList",
Public = true,
ListView = @"[{""fld"": ""widgetname"",""filter"": {""items"": [{""op"": ""%-"",""value"": ""Generic""}]}}]"
};
//Create and save to db
using (var cct = ServiceProviderProvider.DBContext)
{
await DataListViewBiz.GetBiz(cct).CreateAsync(dlv);
}
dlv = new DataListView()
{
Name = "Name starts with awesome",
UserId = 1,
ListKey = "TestWidgetDataList",
Public = true,
ListView = @"[{""fld"": ""widgetname"",""filter"": {""items"": [{""op"": ""%-"",""value"": ""Awesome""}]}}]"
};
//Create and save to db
using (var cct = ServiceProviderProvider.DBContext)
{
await DataListViewBiz.GetBiz(cct).CreateAsync(dlv);
}
}
//Seed special test data for integration testing
//log.LogInformation("Seeding known users");
await SeedKnownUsersAsync(log);