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);
                IsWindowOpen = false;
            }
        }
Beispiel #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();
        }
Beispiel #3
0
        public async void OnProductsUpdated(ProductUpdatedBatchEventArgs args)
        {
            if (args == null || args.ProductIds == null) return;

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