コード例 #1
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);
        }
コード例 #2
0
        public async Task <bool> UpdateFeaturedContents(string categoryId, Stream featuredContents)
        {
            bool operationStatus = false;

            ProfileDetails profileDetails;

            if (ValidateAuthentication(true, out profileDetails))
            {
                IProfileService profileService = DependencyResolver.Current.GetService(typeof(IProfileService)) as IProfileService;
                profileDetails = profileService.GetProfile(profileDetails.PUID);
                if (profileDetails != null)
                {
                    string input;
                    using (StreamReader sr = new StreamReader(featuredContents))
                    {
                        input = sr.ReadToEnd();
                    }

                    if (!string.IsNullOrWhiteSpace(input))
                    {
                        AdminEntityDetailsList contents = input.DeserializeXML <AdminEntityDetailsList>();
                        if (contents != null && contents.FeaturedEntities != null)
                        {
                            IFeaturedEntityService featuredEntityService = DependencyResolver.Current.GetService(typeof(IFeaturedEntityService)) as IFeaturedEntityService;
                            var status = await featuredEntityService.UpdateFeaturedContents(contents.FeaturedEntities, profileDetails.ID, GetCategoryId(categoryId));

                            operationStatus = status.Succeeded;
                        }
                    }
                }
                else
                {
                    throw new WebFaultException <string>(Resources.UserNotRegisteredMessage, HttpStatusCode.Unauthorized);
                }
            }

            return(operationStatus);
        }
コード例 #3
0
        public async Task <AdminEntityDetailsList> GetContents(string categoryId)
        {
            AdminEntityDetailsList result = new AdminEntityDetailsList();

            ProfileDetails profileDetails;

            if (ValidateAuthentication(true, out profileDetails))
            {
                IProfileService profileService = DependencyResolver.Current.GetService(typeof(IProfileService)) as IProfileService;
                profileDetails = profileService.GetProfile(profileDetails.PUID);
                if (profileDetails != null)
                {
                    result.FeaturedEntities = await GetContents(HighlightType.Featured, categoryId, new List <long>());

                    result.Entities = await GetContents(HighlightType.None, categoryId, result.FeaturedEntities.Select(c => c.EntityID).ToList());
                }
                else
                {
                    throw new WebFaultException <string>(Resources.UserNotRegisteredMessage, HttpStatusCode.Unauthorized);
                }
            }
            return(result);
        }