From a653ff4963fd0d6433d2c74ff1262c9c5d9cddfe Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 28 Jan 2020 18:52:21 +0000 Subject: [PATCH] --- server/AyaNova/biz/FormCustomBiz.cs | 14 ++++++-------- server/AyaNova/biz/UserBiz.cs | 13 ++++++------- server/AyaNova/util/Seeder.cs | 4 ++-- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/server/AyaNova/biz/FormCustomBiz.cs b/server/AyaNova/biz/FormCustomBiz.cs index 85f6189d..59235bb1 100644 --- a/server/AyaNova/biz/FormCustomBiz.cs +++ b/server/AyaNova/biz/FormCustomBiz.cs @@ -24,17 +24,15 @@ namespace AyaNova.Biz BizType = AyaType.FormCustom; } - internal static FormCustomBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext) + internal static FormCustomBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null) { - - return new FormCustomBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); + if (httpContext != null) + return new FormCustomBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); + else//when called internally for internal ops there will be no context so need to set default values for that + return new FormCustomBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); } - // //Version for internal use - // internal static FormCustomBiz GetBizInternal(AyContext ct) - // { - // return new FormCustomBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); - // } + //////////////////////////////////////////////////////////////////////////////////////////////// //EXISTS diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index d97a267d..a5a30f46 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -38,16 +38,15 @@ namespace AyaNova.Biz return ret; } - internal static UserBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext) + internal static UserBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null) { - return new UserBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); + if (httpContext != null) + return new UserBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); + else//when called internally for internal ops there will be no context so need to set default values for that + return new UserBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); } - // //Version for internal use - // internal static UserBiz GetBizInternal(AyContext ct) - // { - // return new UserBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); - // } + //////////////////////////////////////////////////////////////////////////////////////////////// //CREATE diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 9bb249e2..f09b0390 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -132,7 +132,7 @@ namespace AyaNova.Util //Create and save to db using (var cct = ServiceProviderProvider.DBContext) { - await FormCustomBiz.GetBizInternal(cct).CreateAsync(fc); + await FormCustomBiz.GetBiz(cct).CreateAsync(fc); } } @@ -516,7 +516,7 @@ namespace AyaNova.Util using (var ct = ServiceProviderProvider.DBContext) { - UserBiz Biz = UserBiz.GetBizInternal(ct); + UserBiz Biz = UserBiz.GetBiz(ct); //allow creation of not entirely ready users (missing client id or subcontractor vendor id etc) Biz.SeedOrImportRelaxedRulesMode = true;