예제 #1
0
        private async void Create_Click(object sender, RoutedEventArgs e)
        {
            ModelManager modelManager = ModelManager.GetInstance();
            JObject      newObj       = new JObject();

            newObj.Add("CreateDefaultGroups", new JValue(DefaultGroupToggleBotton.IsChecked));
            newObj.Add("Description", new JValue(DescriptionBox.Text));
            newObj.Add("Name", new JValue(ProductNameBox.Text));

            List <ProductModel> products = await modelManager.GetProductModels(this.CurrentTenantModel, false);

            foreach (ProductModel model in products)
            {
                if (model.Product == ProductNameBox.Text)
                {
                    MessageBox.Show("Product is already exists",
                                    "Error", MessageBoxButtons.OK);
                    return;
                }
            }

            Cursor = System.Windows.Input.Cursors.Wait;
            this.CreateButton.IsEnabled = false;
            this.CloseButton.IsEnabled  = false;

            if (await modelManager.CreateProductGroup(CurrentTenantModel, newObj.ToString()))
            {
                MessageBox.Show("Create Product is success.",
                                "Ok", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Create Product is failure.",
                                "Error", MessageBoxButtons.OK);
            }
            Cursor = null;
            this.CreateButton.IsEnabled = true;
            this.CloseButton.IsEnabled  = true;
        }