using BBWY.Client.APIServices; using BBWY.Client.Models; using BBWY.Common.Models; using GalaSoft.MvvmLight.Command; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Windows.Input; namespace BBWY.Client.ViewModels { public class BatchPublishTaskViewModel : BaseVM, IDenpendency { PackTaskService packTaskService; ProductService productService; private bool isLoading = false; public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } private ObservableCollection batchPublishTasks; public ObservableCollection BatchPublishTasks { get => batchPublishTasks; set { Set(ref batchPublishTasks, value); } } public ICommand CreateTaskCommand { get; set; } public BatchPublishTaskViewModel(PackTaskService packTaskService, ProductService productService) { BatchPublishTasks = new ObservableCollection(); this.packTaskService = packTaskService; this.productService = productService; CreateTaskCommand = new RelayCommand(CreateTask); } private void CreateTask() { } Platform platform; string orderId; string PurchaserId; public void AddSkus(Platform platform, string orderId, string PurchaserId, List purchaseOrderSkus) { BatchPublishTasks = new ObservableCollection(); this.platform = platform; this.orderId = orderId; this.PurchaserId = PurchaserId; BatchPublishTask model = null; IsLoading = true; foreach (var item in purchaseOrderSkus) { model = new BatchPublishTask(); //model.InitData(); model.productService = productService; model.packTaskService = packTaskService; model.SkuId = item.SkuId; model.SkuCount = item.Quantity.Value; model.Logo = item.Logo; model.SpuId = item.ProductId; model.SkuName = item.SkuTitle; model.SearchSku(item.SkuId); App.Current.Dispatcher.Invoke(() => { BatchPublishTasks.Add(model); }); } IsLoading = false; } } }