コード例 #1
0
        private static async Task<Collection<AdminEntityDetails>> GetContents(HighlightType highlightType, string categoryId, List<long> doNotInclude)
        {
            Collection<AdminEntityDetails> entities = new Collection<AdminEntityDetails>();
            IEntityService entityService = DependencyResolver.Current.GetService(typeof(IEntityService)) as IEntityService;
            var results = await entityService.GetContents(new EntityHighlightFilter(highlightType, int.Parse(categoryId, CultureInfo.InvariantCulture).ToEnum<int, CategoryType>(CategoryType.All), null));

            foreach (var item in results.Where(fc => !doNotInclude.Contains(fc.ID)))
            {
                AdminEntityDetails entity = new AdminEntityDetails();
                Mapper.Map(item, entity);
                entity.CategoryName = Resources.ResourceManager.GetString(item.CategoryID.ToEnum<int, CategoryType>(CategoryType.All).ToString(), Resources.Culture);

                entities.Add(entity);
            }

            return entities;
        }
コード例 #2
0
        public async Task<AdminEntityDetailsList> GetAllContents(string categoryId)
        {
            AdminEntityDetailsList adminEntityDetailsList = new AdminEntityDetailsList();
            adminEntityDetailsList.Entities = new Collection<AdminEntityDetails>();

            ProfileDetails profileDetails;

            if (ValidateAuthentication(true, out profileDetails))
            {
                IProfileService profileService = DependencyResolver.Current.GetService(typeof(IProfileService)) as IProfileService;
                profileDetails = profileService.GetProfile(profileDetails.PUID);
                if (profileDetails != null)
                {
                    IEntityService entityService = DependencyResolver.Current.GetService(typeof(IEntityService)) as IEntityService;
                    foreach (var item in await entityService.GetAllContents(profileDetails.ID, GetCategoryId(categoryId)))
                    {
                        AdminEntityDetails entity = new AdminEntityDetails();
                        Mapper.Map(item, entity);
                        entity.CategoryName = Resources.ResourceManager.GetString(item.CategoryID.ToEnum<int, CategoryType>(CategoryType.All).ToString(), Resources.Culture);

                        adminEntityDetailsList.Entities.Add(entity);
                    }
                }
                else
                {
                    throw new WebFaultException<string>(Resources.UserNotRegisteredMessage, HttpStatusCode.Unauthorized);
                }
            }

            return adminEntityDetailsList;
        }