public DayScheduleViewModel(GKDaySchedule daySchedule) { DaySchedule = daySchedule; AddCommand = new RelayCommand(OnAdd, CanAdd); EditCommand = new RelayCommand(OnEdit, CanEdit); RemoveCommand = new RelayCommand(OnRemove, CanEdit); DaySchedule = daySchedule; Parts = new ObservableCollection<DaySchedulePartViewModel>(); foreach (var dayIntervalPart in daySchedule.DayScheduleParts) { var daySchedulePartViewModel = new DaySchedulePartViewModel(dayIntervalPart); Parts.Add(daySchedulePartViewModel); } Update(DaySchedule); }
void OnAdd() { var daySchedulePartDetailsViewModel = new DaySchedulePartDetailsViewModel(); if (DialogService.ShowModalWindow(daySchedulePartDetailsViewModel)) { DaySchedule.DayScheduleParts.Add(daySchedulePartDetailsViewModel.DaySchedulePart); if (GKScheduleHelper.SaveDaySchedule(DaySchedule, false)) { var daySchedulePartViewModel = new DaySchedulePartViewModel(daySchedulePartDetailsViewModel.DaySchedulePart); Parts.Add(daySchedulePartViewModel); SelectedPart = daySchedulePartViewModel; } } }