Ejemplo n.º 1
0
        // //////////////////////////////////////////////////////////
        // *** Related Content ***
        // //////////////////////////////////////////////////////////
        private async Task CreateRelatedContentList(MediaLink media)
        {
            // Clear object if not empty
            _relatedContent.Clear();

            // Get the current user's MAC
            var mobileAppConfigurationId = await SettingsDataService.GetCurrentMobileConfigurationID();

            var categories = await _categoryDataService.GetCategories(mobileAppConfigurationId);


            // Get the CatCon list based on MACs
            var categoryContents = await _categoryContentDataService.GetCategoryContent(mobileAppConfigurationId);

            if (categoryContents != null && categoryContents.Any())
            {
                // Filter for the Category List based on the input mediaLink objects Id
                var tempCategoryIdList = (categoryContents.Where(cc => cc.ContentId == media.ID)).Select(x => x.CategoryId).Distinct();

                // Ge thet Parent category Ids and merge
                var parentCategoryIdList = categories.Where(x => tempCategoryIdList.Contains(x.Id)).Select(x => x.ParentCategory).Distinct();
                var categoryIdList       = tempCategoryIdList.Concat(parentCategoryIdList).Distinct();

                if (categoryIdList != null && categoryIdList.Any())
                {
                    // Filter the Content ID List based on the previous category List
                    var contentIds = categoryContents.Where(cc => categoryIdList.Contains(cc.CategoryId) && cc.ContentId != media.ID).Select(x => x.ContentId).Distinct();
                    if (contentIds != null && contentIds.Any())
                    {
                        // Generate the MediaLink List
                        var docInfoList = await _documentInfoDataService.GetContentDocumentsByID(contentIds);

                        if (docInfoList != null && docInfoList.Any())
                        {
                            _relatedContent = docInfoList.Select(d => new MediaLink(d)).ToList();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <List <CategoryInfo> > GetCategoryInfos()
        {
            var mobileAppConfigurationId = await _settingsDataService.GetCurrentMobileConfigurationID();

            var mobileConfigCategories = await _categoryMobileConfigDataService.GetCategoryMobileConfigs(mobileAppConfigurationId);

            var categories = await _categoryDataService.GetCategories(mobileAppConfigurationId);

            var categoriesContent = await _categoryContentDataService.GetCategoryContent(mobileAppConfigurationId);

            var contentsID = categoriesContent.Select(cc => cc.ContentId15);

            var content = await _documentInfoDataService.GetContentDocumentsById15(contentsID);

            var documentsList = categoriesContent
                                .Join(content, cc => cc.ContentId15, cd => cd.Document.Id15, (cc, cd) => new { CategoryContent = cc, Document = cd });

            return(categories
                   .Join(mobileConfigCategories, mcc => mcc.Id, c => c.CategoryId, (c, mcc) => new { Config = mcc, Category = c })
                   .GroupJoin(documentsList, mc => mc.Category.Id, d => d.CategoryContent.CategoryId, (mc, ds) => new CategoryInfo {
                Config = mc.Config, Category = mc.Category, Documents = ds.Select(d => d.Document).ToList()
            })
                   .ToList());
        }