public async Task DeleteProduct(RedemptionStoreProductViewModel product) { if (await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.ConfirmRedemptionStoreProductDeletion)) { this.Products.Remove(product); } this.SelectedProduct = null; }
public RedemptionStoreWindowViewModel() { foreach (RedemptionStoreProductModel product in ChannelSession.Settings.RedemptionStoreProducts.Values.ToList().OrderBy(p => p.Name)) { this.Products.Add(new RedemptionStoreProductViewModel(this, product)); } this.ChatPurchaseCommand = ChannelSession.Settings.RedemptionStoreChatPurchaseCommand; this.ModRedeemCommand = ChannelSession.Settings.RedemptionStoreModRedeemCommand; this.ManualRedeemNeededCommand = ChannelSession.Settings.GetCustomCommand(ChannelSession.Settings.RedemptionStoreManualRedeemNeededCommandID); this.DefaultRedemptionCommand = ChannelSession.Settings.GetCustomCommand(ChannelSession.Settings.RedemptionStoreDefaultRedemptionCommandID); this.SaveProductCommand = this.CreateCommand(async(parameter) => { if (string.IsNullOrEmpty(this.ProductName)) { await DialogHelper.ShowMessage(MixItUp.Base.Resources.ValidProductName); return; } RedemptionStoreProductViewModel duplicateProduct = this.Products.FirstOrDefault(p => p.Name.Equals(this.ProductName)); if (duplicateProduct != null && duplicateProduct.Product != this.SelectedProduct) { await DialogHelper.ShowMessage(MixItUp.Base.Resources.ProductNameAlreadyExists); return; } if (!await this.ProductRequirements.Validate()) { return; } RedemptionStoreProductModel product = this.SelectedProduct; if (this.SelectedProduct == null) { product = new RedemptionStoreProductModel(); } product.Name = this.ProductName; product.MaxAmount = product.CurrentAmount = this.ProductQuantity; product.AutoReplenish = this.ProductAutoReplenish; product.AutoRedeem = this.ProductAutoRedeem; product.Requirements = this.ProductRequirements.GetRequirements(); if (this.SelectedProduct == null) { this.Products.Add(new RedemptionStoreProductViewModel(this, product)); } this.SelectedProduct = null; this.RefreshProducts(); }); }
public void EditProduct(RedemptionStoreProductViewModel product) { this.SelectedProduct = product.Product; }