public void CategoryViewModelTest() { CategoryViewModel expense = Application.Categories.First(cwm => cwm.Type == CategoryType.Expense); Assert.IsNotNull(expense); CategoryViewModel newExpense = new CategoryViewModel(Database, expense, new Category("Test", -1, CategoryType.Expense, 1.0)); Assert.IsNotNull(newExpense); Assert.AreEqual(newExpense.Name, "Test"); }
public CategoryViewModel(ICategoriesManager categoriesManager, CategoryViewModel parent, Category category) : this(category) { m_categoriesManager = categoriesManager; m_parent = parent; WatchChildren(); }
public void UpdateUnderlyingDataTest() { CategoryViewModel newExpense = new CategoryViewModel(Database, new Category("Test 1", -1, CategoryType.Expense, 1.0)); Assert.IsNotNull(newExpense); Assert.AreEqual(newExpense.Name, "Test 1"); Assert.AreEqual(newExpense.UnderlyingData.name, "Test 1"); newExpense.Name = "Test 2"; Assert.AreEqual(newExpense.Name, "Test 2"); Assert.AreEqual(newExpense.UnderlyingData.name, "Test 1"); newExpense.UpdateUnderlyingData(); Assert.AreEqual(newExpense.Name, "Test 2"); Assert.AreEqual(newExpense.UnderlyingData.name, "Test 2"); }
private void CheckCanDrop(CategoryViewModel currentCategory, DragEventArgs e) { e.Effects = DragDropEffects.None; if (null == currentCategory) return; if (!e.Data.GetDataPresent("Category")) return; e.Handled = true; CategoryViewModel category = (CategoryViewModel)e.Data.GetData("Category"); if (null == category) return; if (category.IsCovers(currentCategory)) return; e.Effects = DragDropEffects.Move; }
internal void AdjustParent(AccountancyApplication app) { m_parent = app.GetCategory(m_underlyingData.categoryId); }
public bool IsCovers(CategoryViewModel category) { CategoryViewModel c = category; while (null != c) { if (c.CategoryId == CategoryId) return true; c = c.Parent; } return false; }
private void BuildObjectCollections() { Users = new ObservableCollection<PersonViewModel>(m_database.EnumAllUsers().Select(p => GetPerson(p))); Accounts = new ObservableCollection<AccountViewModel>(m_database.EnumAllAccounts().Select(a => GetAccount(a))); Categories = new ObservableCollection<CategoryViewModel>(m_database.EnumAllCategories().Select(c => new CategoryViewModel(m_database, c))); Categories.ForEach(c => c.AdjustParent(this)); Expenses = new ObservableCollection<ExpenseViewModel>(m_database.EnumAllExpenses().Select(e => new ExpenseViewModel(e, this))); VirtualRoot = new CategoryViewModel(m_database, null, new Category("Virtual", 0, CategoryType.Expense, 0.0)); Reports = new ObservableCollection<OlapView>(m_database.Reports); }
public void RemoveCategory(CategoryViewModel category) { m_database.Delete(category.UnderlyingData); category.Parent.Children.Remove(category); Categories.Remove(GetCategory(category.CategoryId)); }
public void ChangeCategoryParent(CategoryViewModel category, CategoryViewModel newParent) { throw new NotImplementedException(); }
public void ChangeCategoryOrder(CategoryViewModel category, CategoryViewModel categoryBefore) { throw new NotImplementedException(); }
public void ChangeCategory(CategoryViewModel category, string newName, CategoryType type) { Category cat = category.UnderlyingData; cat.name = newName; cat.type = type; m_database.Update(cat); category.Name = newName; category.Type = type; category.UpdateUnderlyingData(); }
public CategoryViewModel AddChildCategory(CategoryViewModel category, string name, CategoryType type) { long catId = m_database.Add(name, category.CategoryId, type); Category c = new Category(name, catId, category.CategoryId, type, double.NaN); CategoryViewModel newCategory = new CategoryViewModel(m_database, category, c); category.Children.Add(newCategory); Categories.Add(newCategory); return newCategory; }
public ExpenseViewModel(long amount, CategoryViewModel category, AccountViewModel account, string description, AccountancyApplication app) : this(new Expense(0, account.AccountId, amount, category.CategoryId, app.SelectedDate, description), app) { }
public void CategoryViewModelTest1() { CategoryViewModel newExpense = new CategoryViewModel(Database, new Category("Test 1", -1, CategoryType.Expense, 1.0)); Assert.IsNotNull(newExpense); Assert.AreEqual(newExpense.Name, "Test 1"); }