public void OnNavigatedTo(INavigationParameters parameters) { for (int i = 0; i < 10; i++) { ProductItemList.Add(new ProductItem { id = i, Name = $"產品名稱{i}", Description = $"規格說明{i}" }); } }
private async Task SearchProducts() { if (!SearchSectionCurrentLoading[ServiceBroker.SearchFilters.Product]) { if (ProductsMore) { try { LoadingCounter++; var Result = await Broker.SearchProducts(AppBase.Current.SearchTerm, SearchSectionCurrentPage[ServiceBroker.SearchFilters.Product]); this.ProductsItemsLabel = string.Format("{0} ({1})", International.Translation.Devices, Result.totalResults); this.ProductsMore = Result.moreResults; foreach (var item in Result.results) { var newItem = new ProductItemList { Title = item.title, Summary = item.text, Price = item.price, UniqueId = item.url }; if (item.image != null) { newItem.ImageUrl = item.image.thumbnail.Replace(".thumbnail", ".standard"); } if (!Products.Contains(newItem)) { Products.Add(newItem); } } SearchSectionCurrentPage[ServiceBroker.SearchFilters.Product] += 1; if (Result.totalResults == 0) { ProductsDescription = International.Translation.NoProductsFound; } else { ProductsDescription = string.Empty; } LoadingCounter--; } catch (Exception) { LoadingCounter--; //await _uxService.ShowAlert(International.Translation.ErrorSearchDevices); } } } }
private async Task ItemsTresholdReached() { if (IsBusy) { return; } if (CurrentPage >= TotalPages) { return; } if (ProductItemList == null || ProductItemList.Count == 0) { return; } IsBusy = true; try { CurrentPage++; var items = await LoadProductList(SearchText, CurrentPage); var previousLastItem = ProductItemList.Last(); foreach (var item in items.Products) { ProductItemList.Add(item); } Debug.WriteLine($"{items.Products.Count()} {ProductItemList.Count} "); if (items.Products.Count() == 0) { ItemTreshold = -1; return; } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task Consume(ConsumeContext <ProductItemCreatedMessage> context) { var message = context.Message; var dbMessage = await messageService.GetByID(message.ID); var r = await supplierService.GetByID(message.SupplierID); ProductItemList l = new ProductItemList { DeliveryTime = message.DeliveryTime, Description = message.Description, ID = message.ProductItemID, NrIntern = message.NrIntern, PricePerPQ = message.PricePerPQ, SupplierEmail = r.Email, SupplierName = r.Name, Title = message.Title, URL = message.URL }; await productItemListService.SaveEntity(l); }