private void OnAddTimesheetEntry(object parameter) { var timesheetEntryViewModel = new TimesheetEntryDialogViewModel { Entry = new TimesheetEntry() }; bool?success = _dialogService.ShowDialog(this, timesheetEntryViewModel); if (success.GetValueOrDefault()) { TimesheetEntries.Insert(0, timesheetEntryViewModel.Entry); } }
private void OnEditTimesheetEntry(object parameter) { var timesheetEntry = parameter as TimesheetEntry; if (timesheetEntry == null) { return; } var toEdit = _service.GetTimesheetEntryById(timesheetEntry.Id); var timesheetEntryViewModel = new TimesheetEntryDialogViewModel { Entry = toEdit }; var success = _dialogService.ShowDialog(this, timesheetEntryViewModel); if (success.GetValueOrDefault()) { var index = TimesheetEntries.IndexOf(timesheetEntry); TimesheetEntries.Remove(timesheetEntry); TimesheetEntries.Insert(index, timesheetEntryViewModel.Entry); } }