コード例 #1
0
        public async Task <JObject> GetAsync(int id)
        {
            var languageAndCulture = await _contentManagementContext.LanguageAndCultures.Where(ln => ln.Id == id).Include(ln => ln.Flag).FirstOrDefaultAsync();


            if (languageAndCulture == null)
            {
                return(null);
            }
            AuthorizeManager.CheckViewAccess(languageAndCulture);
            return(await ConvertToJsonAsync(languageAndCulture));
        }
コード例 #2
0
        public async Task <JObject> GetAsync(int id)
        {
            var masterDataQuery = ContentManagementContext.MasterDataKeyValues.Where(sr => sr.Id == id).FutureFirstOrDefault();
            var maxIdQuery      = ContentManagementContext.MasterDataKeyValues.OrderByDescending(md => md.Id).FutureFirstOrDefault();

            var masterData = masterDataQuery.Value;
            var maxId      = maxIdQuery.Value;

            if (masterData == null)
            {
                return(null);
            }
            AuthorizeManager.CheckViewAccess(masterData);
            return(await  ConvertToJsonAsync(masterData, maxId.Id + 1));
        }
コード例 #3
0
        public async Task <JObject> GetAsync(int id)
        {
            var serviceQuery = _contentManagementContext
                               .MasterDataKeyValues.Where(sr => sr.Id == id && sr.TypeId == (int)EntityIdentity.Service).FutureFirstOrDefault();
            var maxIdQuery = _contentManagementContext.MasterDataKeyValues.OrderByDescending(md => md.Id).FutureFirstOrDefault();

            var service = serviceQuery.Value;
            var maxId   = maxIdQuery.Value;

            if (service == null)
            {
                return(null);
            }
            AuthorizeManager.CheckViewAccess(service);
            if (!AuthorizeManager.IsAuthorizeToViewSourceCodeOfService(service.Id))
            {
                throw new UnauthorizedAccessException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidGrant));
            }
            return(await ConvertToJsonAsync(service, maxId.Id + 1));
        }