From f0e2de82ea8d994378a9f664548962bbdbacb80d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 18 Feb 2020 16:23:25 +0000 Subject: [PATCH] --- server/AyaNova/biz/DataListViewBiz.cs | 15 +++++----- server/AyaNova/util/Seeder.cs | 41 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/server/AyaNova/biz/DataListViewBiz.cs b/server/AyaNova/biz/DataListViewBiz.cs index 60423b87..f2d0d3c9 100644 --- a/server/AyaNova/biz/DataListViewBiz.cs +++ b/server/AyaNova/biz/DataListViewBiz.cs @@ -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 diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 382ff0d8..6ca42624 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -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);