Beispiel #1
0
 /// <summary>
 ///     Edit the selected field of current tab
 /// </summary>
 /// <param name="field"></param>
 public void EditField(string field)
 {
     switch (field)
     {
     case "Category":
         if (SelectedCategory != null)
         {
             FieldEditWindowView window = new FieldEditWindowView();
             window.DataContext = new FieldEditWindowViewModel("Category", SelectedCategory, "Update", ItemService, EmailService);
             window.ShowDialog();
             if (window.DialogResult == true)
             {
                 string newValue      = (window.DataContext as FieldEditWindowViewModel).NewFieldValue;
                 string originalValue = (window.DataContext as FieldEditWindowViewModel).OriginalFieldValue;
                 Categories.Remove(originalValue);
                 Categories.Add(newValue);
                 Categories = new ObservableCollection <string>(Categories.OrderBy(i => i));
             }
         }
         else
         {
             MessageBox.Show("Please Select a category to edit");
         }
         break;
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Adds 'categoryInput' to categories table and reloads the table
        /// </summary>
        public void CreateField(string field)
        {
            FieldEditWindowView window = new FieldEditWindowView();

            window.DataContext = new FieldEditWindowViewModel(fieldType: field, fieldValue: "", fieldStatus: "Add", itemService: ItemService, emailService: EmailService);
            window.ShowDialog();
            if (window.DialogResult == true)
            {
                string newValue = "";
                switch (field)
                {
                case "Category":
                    newValue = (window.DataContext as FieldEditWindowViewModel).NewFieldValue;
                    Categories.Add(newValue);
                    Categories = new ObservableCollection <string>(Categories.OrderBy(i => i));
                    break;

                case "License":
                    newValue = (window.DataContext as FieldEditWindowViewModel).NewFieldValue;
                    Licenses.Add(newValue);
                    Licenses = new ObservableCollection <string>(Licenses.OrderBy(i => i));
                    break;

                case "Meta Description":
                    newValue = (window.DataContext as FieldEditWindowViewModel).NewFieldValue;
                    MetaDescriptions.Add(newValue);
                    MetaDescriptions = new ObservableCollection <string>(MetaDescriptions.OrderBy(i => i));
                    break;

                case "Territory":
                    newValue = (window.DataContext as FieldEditWindowViewModel).NewFieldValue;
                    Territories.Add(newValue);
                    Territories = new ObservableCollection <string>(Territories.OrderBy(i => i));
                    break;
                }
            }
        }