Exemplo n.º 1
0
 private void CategoryChanged(int pageId)
 {
     SelectedHotCategory = HotCategories.FirstOrDefault(x => x.PageId == pageId);
     if (SelectedHotCategory?.ProductDetails == null || SelectedHotCategory?.ProductDetails.Count == 0)
     {
         LoadHotProducts(pageId);
     }
 }
Exemplo n.º 2
0
        private void UpdateQuantities(ObservableCollection <SaleLineModel> saleLines)
        {
            foreach (var x in HotCategories)
            {
                foreach (var hx in x.ProductDetails)
                {
                    hx.Quantity = (int)saleLines.Where(y => y.Code == hx.StockCode).
                                  Sum(z => double.Parse(z.Quantity, CultureInfo.InvariantCulture));
                }
            }

            var selectedHotProduct = SelectedHotCategory?.PageId;

            if (selectedHotProduct.HasValue && selectedHotProduct.Value != 0)
            {
                SelectedHotCategory = HotCategories.FirstOrDefault(x => x.PageId == selectedHotProduct);
            }
        }
Exemplo n.º 3
0
        private async void LoadHotProducts(int pageId)
        {
            try
            {
                var hotProducts = await _stockBussinessLogic.GetHotProducts(pageId);

                var productDetails = new ObservableCollection <ProductDataModel>();

                foreach (var product in hotProducts)
                {
                    var productDetail = new ProductDataModel
                    {
                        DefaultQuantity = Convert.ToInt32(product.DefaultQuantity, CultureInfo.InvariantCulture),
                        Description     = product.Description,
                        ImageSource     = new BitmapImage
                        {
                            UriSource = Helper.IsValidURI(product.Image) ? new Uri(product.Image) :
                                        null
                        },
                        StockCode = product.StockCode
                    };

                    productDetails.Add(productDetail);
                }

                HotCategories.FirstOrDefault(x => x.PageId == pageId).ProductDetails = productDetails;

                MessengerInstance.Send(new RequestForSyncHotProductsMessage());
            }
            finally
            {
                OperationsCompletedInLogin++;
                if (IsSwitchUserStarted)
                {
                    OperationsCompletedInSwitchUser++;
                }
            }
        }