Exemplo n.º 1
0
 private void SubCategorySelector_SubCategorySelectionChanged(SubCategoryItemDTO subCategoryDTO)
 {
     if (SubCategorySelectionChanged != null)
     {
         SubCategorySelectionChanged(subCategoryDTO);
     }
 }
        public SubCategoryItemDTO CloneSubCategoryItemEntity(Data.Entities.SubCategoryItem subCategoryItem)
        {
            SubCategoryItemDTO subCategoryItemDTO = new SubCategoryItemDTO
            {
                ItemId        = subCategoryItem.ItemId,
                SubCategoryId = subCategoryItem.SubCategoryId,
            };

            return(subCategoryItemDTO);
        }
        public async IAsyncEnumerable <SubCategoryItemDTO> GetItemBySubCategoryAsync(Guid subCategoryId)
        {
            List <Data.Entities.SubCategoryItem> subCategoryItemList = await _context.SubCategoryItem.Where(a => a.SubCategoryId == subCategoryId).ToListAsync();

            foreach (var subCategoryItem in subCategoryItemList)
            {
                SubCategoryItemDTO subCategoryItemDTO = CloneSubCategoryItemEntity(subCategoryItem);

                yield return(subCategoryItemDTO);
            }
        }
Exemplo n.º 4
0
        internal ObservableCollection <SubCategoryItemDTO> GetFanFicSubCategories(string SubCategoryUri)
        {
            try
            {
                bool scrapeSucceeded = true;

                ObservableCollection <SubCategoryItemDTO> result = new ObservableCollection <SubCategoryItemDTO>();

                byte[] mainPageHtml = _webClient.DownloadData(string.Format(_baseUri, SubCategoryUri));
                string source       = Encoding.GetEncoding("iso-8859-1").GetString(mainPageHtml, 0, mainPageHtml.Length - 1);
                source = WebUtility.HtmlDecode(source);
                _decoder.LoadHtml(source);

                HtmlNode subCategoriesNodes = _decoder.DocumentNode.Descendants().FirstOrDefault(x => (x.Name == "table" &&
                                                                                                       x.Attributes["align"] != null &&
                                                                                                       x.Attributes["align"].Value.Contains("center")));

                if (subCategoriesNodes != null)
                {
                    List <HtmlNode> subCategories = subCategoriesNodes.Descendants().Where(x => (x.Name == "div" &&
                                                                                                 x.Attributes["style"] != null)).ToList();
                    if (subCategories != null)
                    {
                        foreach (HtmlNode subCategory in subCategories)
                        {
                            SubCategoryItemDTO subCategoryInfo = ScreapeSubCategoryInformation(subCategory);
                            if (subCategoryInfo != null)
                            {
                                result.Add(subCategoryInfo);
                            }
                        }
                    }
                    else
                    {
                        scrapeSucceeded = false;
                    }
                }
                else
                {
                    scrapeSucceeded = false;
                }

                if (!scrapeSucceeded)
                {
                    //TODO: Advise user that nothing has been found and disable UI
                }

                return(result);
            } catch (Exception e)
            {
                return(new ObservableCollection <SubCategoryItemDTO>());
            }
        }
Exemplo n.º 5
0
        private void _categoryPage_SubCategorySelectionChanged(SubCategoryItemDTO subCategoryItemDTO)
        {
            if (subCategoryItemDTO == null || subCategoryItemDTO.FanFicsPageUri == string.Empty)
            {
                return;
            }

            _selectedSubCategory = subCategoryItemDTO;

            CurrentCategoryViewModel            = InitiateFanFicPage(subCategoryItemDTO.FanFicsPageUri);
            _fanFicPageViewModel.CategoryName   = _categoryPageViewModel.CategoryName;
            _fanFicPageViewModel.FanFicPageName = subCategoryItemDTO.SubCategoryName;
        }