Exemplo n.º 1
0
		private void SetCategory (Category category)
		{
			CurrentCategory = category;

			Name = CurrentCategory.Name;
			if (CurrentCategory.ParentId != null) {
				var parentCategory = App.Settings.Categories.GetCategoryById (CurrentCategory.ParentId.Value);

				CanGoBack = true;
				ParentName = parentCategory.Name;
			} else {
				CanGoBack = false;
			}

			if (SubCategories != null && SubCategories.Count != 0) {
				foreach (var item in SubCategories) {
					item.Deleted -= OnSubCategoryDeleted;
				}
			}
			var categories = App.Settings.Categories.GetChildCategories (category.Id.Value);
			SubCategories = new ObservableCollection<CategoryViewModel> (categories.Select (c => new CategoryViewModel (c)));
			foreach (var item in SubCategories) {
				item.Deleted += OnSubCategoryDeleted;
			}
		}
Exemplo n.º 2
0
		public SelectCategoryViewModel (Category category)
		{
			category = category ?? App.Settings.Categories.GetDefaultCategory ();

			SetCategory (category);

			AddSubCategoryCommand = new Command (AddSubCategoryExecute);
			GoBackCommand = new Command (GoBackCommandExecute);
		}
Exemplo n.º 3
0
		public CategoryViewModel (Category category)
		{
			Model = category;

			DeleteCommand = new Command (DeleteCommandExecute);
		}