Пример #1
0
 public async Task DeleteProduct(RedemptionStoreProductViewModel product)
 {
     if (await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.ConfirmRedemptionStoreProductDeletion))
     {
         this.Products.Remove(product);
     }
     this.SelectedProduct = null;
 }
Пример #2
0
        public RedemptionStoreWindowViewModel()
        {
            this.Products.AddRange(ChannelSession.Settings.RedemptionStoreProducts.Values.ToList().OrderBy(p => p.Name).Select(p => new RedemptionStoreProductViewModel(this, p)));

            this.ChatPurchaseCommand = ChannelSession.Settings.RedemptionStoreChatPurchaseCommand;
            this.ModRedeemCommand    = ChannelSession.Settings.RedemptionStoreModRedeemCommand;

            this.ManualRedeemNeededCommand = (CustomCommandModel)ChannelSession.Settings.GetCommand(ChannelSession.Settings.RedemptionStoreManualRedeemNeededCommandID);
            this.DefaultRedemptionCommand  = (CustomCommandModel)ChannelSession.Settings.GetCommand(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;
                }

                IEnumerable <Result> requirementResults = await this.ProductRequirements.Validate();
                if (requirementResults.Any(r => !r.Success))
                {
                    await DialogHelper.ShowMessage(string.Join(Environment.NewLine, requirementResults.Where(r => !r.Success).Select(r => r.Message)));
                }

                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();
            });
        }
Пример #3
0
 public void EditProduct(RedemptionStoreProductViewModel product)
 {
     this.SelectedProduct = product.Product;
 }