summaryrefslogtreecommitdiff
path: root/src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs')
-rw-r--r--src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs b/src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs
index cfe1ae8..609f5b9 100644
--- a/src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs
+++ b/src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Linq.Expressions;
+using System.Windows;
using MVPtoMVVM.domain;
using MVPtoMVVM.repositories;
using System.Linq;
@@ -24,7 +26,7 @@ namespace MVPtoMVVM.mvvm.viewmodels
this.todoItemRepository = todoItemRepository;
SaveCommand = new SimpleCommand(Save, CanSave);
DeleteCommand = new SimpleCommand(Delete);
- synchronizer = new Synchronizer<TodoItemViewModel>(PropertyChanged);
+ synchronizer = new Synchronizer<TodoItemViewModel>(() => PropertyChanged);
validations = new Dictionary<string, IValidation>
{
{"Description", new Validation(() => !string.IsNullOrEmpty(Description), "Cannot have an empty description.")},
@@ -60,11 +62,16 @@ namespace MVPtoMVVM.mvvm.viewmodels
{
description = value;
IsDirty = true;
- synchronizer.Update(x => x.Description);
+ Update(x => x.Description);
SaveCommand.Changed();
}
}
+ private void Update(Expression<Func<TodoItemViewModel, object>> func)
+ {
+ synchronizer.Update(this, func);
+ }
+
private DateTime dueDate;
public DateTime DueDate
{
@@ -73,17 +80,17 @@ namespace MVPtoMVVM.mvvm.viewmodels
{
dueDate = value;
IsDirty = true;
- synchronizer.Update(x => x.DueDate);
- synchronizer.Update(x => x.ShowDueSoonAlert);
+ Update(x => x.DueDate);
+ Update(x => x.ShowDueSoonAlert);
SaveCommand.Changed();
}
}
- public bool ShowDueSoonAlert
+ public Visibility ShowDueSoonAlert
{
get
{
- return DueDate <= DateTime.Today.AddDays(1);
+ return DueDate <= DateTime.Today.AddDays(1) ? Visibility.Visible : Visibility.Hidden;
}
}