public ToDoViewModel(IDialogService dialogService, MainWindowViewModel mainWindowViewModel, ToDo toDo) { this.dialogService = dialogService; this.mainWindowViewModel = mainWindowViewModel; mainWindowViewModel.ViewTitle = "Εκκρεμοτητες"; this.db = new CmsContext(); this.People = new ObservableCollection<Person>(db.People.ToList().OrderByDescending(t => t.FullName)); Save = new RelayCommand(save, null); GoBack = new RelayCommand(goBack, null); this.ToDo = toDo; if (this.ToDo == null) { this.ToDo = new ToDo(); this.ToDo.Id = Guid.NewGuid().ToString(); this.ToDo.ToDoDate = DateTime.Now.Date; this.ToDo.Done = false; db.ToDoes.Add(this.ToDo); } else { this.ToDo = db.ToDoes.Find(toDo.Id); } }
private void newToDo(object obj) { var toDo = new ToDo(); toDo.Id = Guid.NewGuid().ToString(); toDo.PersonId = Person.Id; toDo.ToDoDate = DateTime.Now.Date; toDo.Done = false; Person.ToDoes.Add(toDo); SelectedToDo = toDo; mainWindowViewModel.SettingsViewModel = new ToDoFlyOutViewModel(SelectedToDo); mainWindowViewModel.IsSettingsFlyoutOpen = true; }