public AddToDoViewModel(INavigation navigation) { _navigation = navigation; _todoValidator = new ToDoValidator(); _todo = new ToDo(); _todoRepository = new ToDoRepository(); AddToDoCommand = new Command(async() => await AddToDo()); ViewAllToDosCommand = new Command(async() => await ShowToDoList()); }
public DetailsToDoViewModel(INavigation navigation, int selectedToDoID) { _navigation = navigation; _todoValidator = new ToDoValidator(); _todoRepository = new ToDoRepository(); _todo = new ToDo { ID = selectedToDoID }; UpdateToDoCommand = new Command(async() => await UpdateToDo()); DeleteToDoCommand = new Command(async() => await DeleteToDo()); FetchToDoDetails(); }
private void save(object obj) { var validator = new ToDoValidator(); var results = validator.Validate(this.ToDo); if (results.IsValid) { try { db.SaveChanges(); dialogService.ShowMessageAsync("Καταχώρηση", "Οι αλλαγές καταχωρήθηκαν επιτυχώς."); } catch (Exception ex) { dialogService.ShowMessageAsync("Σφάλμα", ex.Message); } } else { var message = string.Join(Environment.NewLine, results.Errors.Select(t => t.ErrorMessage)); dialogService.ShowMessageAsync("Σφάλμα", message); } }
public ToDoController(IToDoAppService appService, ToDoValidator validator) { this.appService = appService; this.validator = validator; }