/// <summary> /// Clears all the global /// </summary> public static void ClearValues() { AccountingGroups.Clear(); CostProfileGroups.Clear(); CountriesOfOrigin.Clear(); CustomerIdConversions.Clear(); ExternalIdTypes.Clear(); ItemCategories.Clear(); ItemGroups.Clear(); ItemIds.Clear(); ItemIdSuffixes.Clear(); ItemRecords.Clear(); Languages.Clear(); Licenses.Clear(); LocalItemIds.Clear(); MetaDescriptions.Clear(); PricingGroups.Clear(); ProductCategories.Clear(); ProductFormats.Clear(); ProductGoups.Clear(); ProductLines.Clear(); Properties.Clear(); PsStatuses.Clear(); RequestStatus.Clear(); SpecialCharacters.Clear(); TariffCodes.Clear(); Territories.Clear(); ToolTips.Clear(); UpcProductFormatExceptions.Clear(); Upcs.Clear(); UserNames.Clear(); UserRoles.Clear(); WebCategoryList.Clear(); }
/// <summary> /// Loads in the lists of fields that can be edited /// </summary> public void LoadFields(bool includeRequests) { Categories = new ObservableCollection <string>(); Licenses = new ObservableCollection <string>(); Territories = new ObservableCollection <string>(); try { List <string> CategoryList = GlobalData.ReturnWebCategoryListValues(); List <string> LicenseList = ItemService.RetrieveLicensePropertyList(); List <string> TerritoryList = GlobalData.Territories; List <string> MetaDescriptionList = GlobalData.MetaDescriptions; CategoryList.Sort(); TerritoryList.Sort(); foreach (string i in CategoryList) { Categories.Add(i); } foreach (string i in MetaDescriptionList) { MetaDescriptions.Add(i); } foreach (string i in LicenseList) { Licenses.Add(i); } foreach (string i in TerritoryList) { Territories.Add(i); } } catch (Exception ex) { ErrorLog.LogError("Odin was unable to retrieve editable field values.", ex.ToString()); } }
/// <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; } } }
/// <summary> /// Removes Selected category from list and reloads the list /// </summary> public void RemoveField(string field) { bool pass = false; switch (field) { case "Category": if (SelectedCategory != null) { try { ItemService.RemoveCategory(SelectedCategory); Categories.Remove(SelectedCategory); pass = true; } catch (Exception ex) { ErrorLog.LogError("Could not remove selected Category.", ex.ToString()); } } else { MessageBox.Show("No Category selected to remove"); } break; case "License": if (SelectedLicense != null) { try { ItemService.RemoveLicense(SelectedLicense); Licenses.Remove(SelectedLicense); pass = true; } catch (Exception ex) { ErrorLog.LogError("Could not remove selected License.", ex.ToString()); } } else { MessageBox.Show("No License selected to remove"); } break; case "Meta Description": if (SelectedMetaDescription != null) { try { ItemService.RemoveMetaDescription(SelectedMetaDescription); MetaDescriptions.Remove(SelectedMetaDescription); pass = true; } catch (Exception ex) { ErrorLog.LogError("Could not remove selected Meta Description.", ex.ToString()); } } else { MessageBox.Show("No License selected to remove"); } break; case "Property": if (SelectedProperty != null) { try { ItemService.RemoveProperty(SelectedProperty); Properties.Remove(SelectedProperty); pass = true; } catch (Exception ex) { ErrorLog.LogError("Could not remove selected Property.", ex.ToString()); } } else { MessageBox.Show("No Property selected to remove"); } break; case "Territory": if (SelectedTerritory != null) { try { ItemService.RemoveTerritory(SelectedTerritory); Territories.Remove(SelectedTerritory); pass = true; } catch (Exception ex) { ErrorLog.LogError("Could not remove selected Territory.", ex.ToString()); } } else { MessageBox.Show("No Territory selected to remove"); } break; } if (pass) { MessageBox.Show(field + " Removed"); } }