private async void Save()
        {
            ValidatePercentage();
            if (HasErrors) return;

            var data = Items.Select(x => new ProductPriceUpdate
            {
                Id = x.Product.Id,
                NewPriceOpt = x.NewPriceOpt,
                NewPriceRozn = x.NewPriceRozn
            }).ToArray();

            IsBusy = true;
            var task = await repository.UpdatePrice(data);
            IsBusy = false;
            if (task.Succeed)
            {
                var ids = Items.Select(x => x.Product.Id).ToList();
                var args = new ProductUpdatedBatchEventArgs(ids, false);
                eventAggregator.GetEvent<ProductUpdatedBatchEvent>().Publish(args);

                Confirmed = task.Succeed;
                IsWindowOpen = false;
            }
        }
Example #2
0
        public void OnProductUpdatedBatchLocal(ProductUpdatedBatchEventArgs e)
        {
            if (e.FromRemote) return;

            // products updated locally
            // we need to notify other clients
            hubProxy.Invoke(ProductUpdatedBatchEvent.HubMethodName, e.ProductIds).Wait();
        }
Example #3
0
        public async void OnProductsUpdated(ProductUpdatedBatchEventArgs args)
        {
            if (args == null || args.ProductIds == null) return;

            var task = await productsRepository.GetManyAsync(args.ProductIds);
            if (task.Succeed)
            {
                foreach (var product in task.Result)
                {
                    UpdateProductItem(product);
                }
                UpdateTotalWeight();
            }
        }
Example #4
0
 private void OnProductUpdatedBatchRemote(List<string> ids)
 {
     Deployment.Current.Dispatcher.BeginInvoke(delegate
     {
         // products updated remotely
         // we need to notify local modules
         var e = new ProductUpdatedBatchEventArgs(ids, true);
         eventAggregator.GetEvent<ProductUpdatedBatchEvent>().Publish(e);
     });
 }