This commit is contained in:
@@ -30,15 +30,13 @@ namespace AyaNova.Biz
|
||||
SeedOrImportRelaxedRulesMode = false;//default
|
||||
}
|
||||
|
||||
internal static LocaleBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
||||
internal static LocaleBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
|
||||
{
|
||||
return new LocaleBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||
}
|
||||
if (httpContext != null)
|
||||
return new LocaleBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||
else
|
||||
return new LocaleBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull);
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +169,8 @@ namespace AyaNova.Biz
|
||||
TrackRequestedKey(param);
|
||||
#endif
|
||||
AyContext ct = ServiceProviderProvider.DBContext;
|
||||
if (!await LocaleExistsStaticAsync(localeId, ct))
|
||||
|
||||
if (!await ct.Locale.AnyAsync(e => e.Id == localeId))
|
||||
localeId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == localeId && param.Contains(x.Key)).AsNoTracking().ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||
return ret;
|
||||
@@ -289,7 +288,7 @@ namespace AyaNova.Biz
|
||||
return false;
|
||||
ct.Locale.Remove(dbObj);
|
||||
await ct.SaveChangesAsync();
|
||||
//Log
|
||||
//Log
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, AyaType.Locale, dbObj.Id, dbObj.Name, ct);
|
||||
return true;
|
||||
}
|
||||
@@ -371,7 +370,8 @@ namespace AyaNova.Biz
|
||||
|
||||
public async Task<bool> LocaleExistsAsync(string localeName)
|
||||
{
|
||||
return await LocaleNameToIdAsync(localeName) != 0;
|
||||
return await ct.Locale.AnyAsync(c => c.Name == localeName);
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> LocaleExistsAsync(long id)
|
||||
@@ -380,13 +380,13 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
public static async Task<bool> LocaleExistsStaticAsync(long id, AyContext ct)
|
||||
{
|
||||
return await ct.Locale.AnyAsync(e => e.Id == id);
|
||||
}
|
||||
// public static async Task<bool> LocaleExistsStaticAsync(long id, AyContext ct)
|
||||
// {
|
||||
// return await ct.Locale.AnyAsync(e => e.Id == id);
|
||||
// }
|
||||
|
||||
|
||||
public static async Task<long> EnsuredLocaleIdStaticAsync(long id, AyContext ct)
|
||||
//this is only called by Search.cs to cache a local cjk and stopwords, no one else calls it currently
|
||||
public static async Task<long> ReturnSpecifiedLocaleIdIfExistsOrDefaultLocaleId(long id, AyContext ct)
|
||||
{
|
||||
if (!await ct.Locale.AnyAsync(e => e.Id == id))
|
||||
return ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||
@@ -622,8 +622,8 @@ namespace AyaNova.Biz
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//this is the equivalent of returning void for a Task signature with nothing to return
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user