Exemplo n.º 1
0
        private void EditJewelry(Object parameter)
        {
            try
            {
                if (SelectedJewelry == string.Empty)
                {
                    MessageBox.Show("Please choose jewelry.");
                    return;
                }

                var     editedIndex   = JewelryList.FindIndex(x => x.ToString() == SelectedJewelry);
                Jewelry editedJewelry = JewelryList.Find(x => x.ToString() == SelectedJewelry);

                if (editedJewelry == null)
                {
                    MessageBox.Show($"Choose one jewerly from dropdown menu.");
                    return;
                }

                editJewelryView.InitJewelryFields(ref editedJewelry);

                JewelryList.RemoveAt(editedIndex);
                JewelryListUI.RemoveAt(editedIndex);
                JewelryList.Add(editedJewelry);
                JewelryListUI.Add(editedJewelry);

                CurrentAppScreen = (int)ApplicationScreen.EditJewelry;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Could not edit jewerly. Reason: {ex.Message}");
            }
        }
Exemplo n.º 2
0
        private void AddJewelry(Object parameter)
        {
            try
            {
                CurrentJewelryMaterials.RemoveAll(x => !IsMaterialAlterred(x));

                if (CurrentJewelryMaterials.Count == 0)
                {
                    MessageBox.Show("No materials were choosen for this jewelry. Please add some.");
                    return;
                }

                if (string.IsNullOrEmpty(JewelryName))
                {
                    MessageBox.Show("Please choose some name for your jewelry.");
                    return;
                }

                var jewelry = jewelryFactory.NewJewelry(SelectedJewelryType);

                var visitor = new JewelryVisitor(this);

                jewelry.Accept(visitor);

                MessageBox.Show($"Successfully added {jewelry.Name}.");

                JewelryList.Add(jewelry);

                JewelryListUI.Add(jewelry);

                ClearFields();

                CurrentJewelryMaterials = null;
                CurrentJewelryMaterials = new List <Material>();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Can't add jewelry. Reason: {ex.Message}.");
            }
        }