コード例 #1
0
ファイル: StartUp.cs プロジェクト: edusolution-project/Edu
        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);
            }
        }
コード例 #2
0
ファイル: StartUp.cs プロジェクト: edusolution-project/Edu
        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);
        }
コード例 #3
0
 public CPResourceController(CPResourceService resourceService)
 {
     _service = resourceService;
 }
コード例 #4
0
 public CPResourceController()
 {
     _service = new CPResourceService();
 }