private static void GetCurrentResource(this HttpContext context, IConfiguration configuration, ref List <CPResourceEntity> currentResource, ref CPLangEntity currentLang) { string cookie = context.GetValue(Cookies.DefaultLang, false); if (string.IsNullOrEmpty(cookie)) { cookie = "vn"; context.SetCurrentLang("VN"); } var lang = new CPLangService(configuration); currentLang = lang.CreateQuery().Find(o => o.IsActive == true && o.Code == cookie)?.SingleOrDefault(); if (currentLang != null) { // cache var cache = CacheExtends.GetDataFromCache <List <CPResourceEntity> >(cookie + "-" + CacheExtends.DefaultLang); // if (cache != null) { currentResource = cache; return; } var res = new CPResourceService(configuration); currentResource = res.GetByLangID(currentLang.ID); } }
private static void GetCurrentResource(this HttpContext context, ref List <CPResourceEntity> currentResource, ref CPLangEntity currentLang) { string cookie = context.GetValue(Cookies.DefaultLang, false); if (string.IsNullOrEmpty(cookie)) { cookie = "vn"; } var lang = new CPLangService(); currentLang = lang.CreateQuery().SelectFirst(o => o.Activity == true && o.Code == cookie); // cache var cache = CacheExtends.GetDataFromCache <List <CPResourceEntity> >(cookie + "-" + CacheExtends.DefaultLang); // if (cache != null) { currentResource = cache; return; } var res = new CPResourceService(); currentResource = res.GetByLangID(currentLang.ID); }