This commit is contained in:
@@ -20,15 +20,27 @@ namespace AyaNova.Biz
|
||||
{
|
||||
public bool SeedOrImportRelaxedRulesMode { get; set; }
|
||||
|
||||
internal LocaleBiz(AyContext dbcontext, long currentUserId, AuthorizationRoles userRoles)
|
||||
internal LocaleBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles userRoles)
|
||||
{
|
||||
ct = dbcontext;
|
||||
UserId = currentUserId;
|
||||
UserLocaleId = userLocaleId;
|
||||
CurrentUserRoles = userRoles;
|
||||
BizType = AyaType.Locale;
|
||||
SeedOrImportRelaxedRulesMode = false;//default
|
||||
}
|
||||
|
||||
internal static LocaleBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
||||
{
|
||||
return new LocaleBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||
}
|
||||
|
||||
//Version for internal use
|
||||
internal static LocaleBiz GetBizInternal(AyContext ct, long currentUserId, AuthorizationRoles roles)
|
||||
{
|
||||
return new LocaleBiz(ct, currentUserId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -141,26 +153,26 @@ namespace AyaNova.Biz
|
||||
#endif
|
||||
|
||||
//Get the keys for a list of keys provided
|
||||
internal async Task<List<KeyValuePair<string, string>>> GetSubset(AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param)
|
||||
internal async Task<List<KeyValuePair<string, string>>> GetSubset(List<string> param)
|
||||
{
|
||||
|
||||
#if (DEBUG)
|
||||
TrackRequestedKey(param.Keys);
|
||||
TrackRequestedKey(param);
|
||||
#endif
|
||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == param.LocaleId && param.Keys.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == UserLocaleId && param.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||
return ret.ToList();
|
||||
}
|
||||
|
||||
//Get the keys for a list of keys provided, static format for calling from other internal classes
|
||||
internal static async Task<List<KeyValuePair<string, string>>> GetSubsetStatic(AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param)
|
||||
internal static async Task<List<KeyValuePair<string, string>>> GetSubsetStatic(List<string> param, long localeId)
|
||||
{
|
||||
#if (DEBUG)
|
||||
TrackRequestedKey(param.Keys);
|
||||
TrackRequestedKey(param);
|
||||
#endif
|
||||
AyContext ct = ServiceProviderProvider.DBContext;
|
||||
if (!LocaleExistsStatic(param.LocaleId, ct))
|
||||
param.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == param.LocaleId && param.Keys.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||
if (!LocaleExistsStatic(localeId, ct))
|
||||
localeId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == localeId && param.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||
return ret.ToList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user