public MainWindowViewModel(ITodoItemRepository todoItemRepository) { this.todoItemRepository = todoItemRepository; AddNewItemCommand = new SimpleCommand(AddNewItem); CancelChangesCommand = new SimpleCommand(RefreshChanges); updater = new Synchronizer<MainWindowViewModel>(() => PropertyChanged); TodoItems = new ObservableCollection<TodoItemViewModel>(); RefreshChanges(); }
public TodoItemViewModel(ITodoItemRepository todoItemRepository) { this.todoItemRepository = todoItemRepository; SaveCommand = new SimpleCommand(Save, CanSave); DeleteCommand = new SimpleCommand(Delete); synchronizer = new Synchronizer<TodoItemViewModel>(() => PropertyChanged); validations = new Dictionary<string, IValidation> { {"Description", new Validation(() => !string.IsNullOrEmpty(Description), "Cannot have an empty description.")}, {"DueDate", new Validation(() => DueDate >= DateTime.Today, "Due Date must occur on or after today.")} }; }