/// <summary>Rename a category in the database.</summary> /// <param name="selectedCategory">Category to rename</param> /// <param name="newName">New name of the Category</param> /// <param name="oldName">Old name of the Category</param> /// <param name="isMajor">Is the category being renamed a Major Category?</param> /// <returns></returns> internal static async Task <bool> RenameCategory(Category selectedCategory, string newName, string oldName, bool isMajor) { bool success = false; if (await DatabaseInteraction.RenameCategory(selectedCategory, newName, oldName, isMajor)) { if (isMajor) { selectedCategory = AllCategories.Find(category => category.Name == selectedCategory.Name); selectedCategory.Name = newName; AllTransactions.Select(transaction => transaction.MajorCategory == oldName ? newName : oldName).ToList(); } else { selectedCategory = AllCategories.Find(category => category.Name == selectedCategory.Name); MinorCategory minor = selectedCategory.MinorCategories.Find(category => category.Name == oldName); minor.Name = newName; AllTransactions.Select(transaction => transaction.MinorCategory == oldName ? newName : oldName).ToList(); } AllCategories = AllCategories.OrderBy(category => category.Name).ToList(); success = true; } return(success); }
public String getMenuName() { return(string.Format("dz191.vhr.{0}.{1}.{2}{3}", MCategory.ToString().ToLower(), MajorCategory.ToString().ToLower(), MinorCategory.ToString().ToLower(), ExtraOptions != null?ExtraOptions.ToLower():"")); }