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; }
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; }