void ApplyProtocolIntoEgeResults(EgeResultCheckProtocolEditorViewModel vm, EntranceExaminationsCheckProtocol protocol) { var exams = vm.GetExaminations(); foreach (var item in exams) { item.EntranceExaminationsCheckProtocol = protocol; } }
void Add() { var protocol = new EntranceExaminationsCheckProtocol(); var entityTypeCollection = new ObservableCollection <EntityType> { new EntityType(SelectableEntity.EgeProtocol), new EntityType(SelectableEntity.InnerExaminationProtocol) }; switch (DialogLayer.ShowEntityTypeSelector(entityTypeCollection)) { case SelectableEntity.EgeProtocol: { var vm = new EgeResultCheckProtocolEditorViewModel(protocol); if (DialogLayer.ShowEditor(EditingContent.EgeResultCheckProtocolEditor, vm)) { Session.DataModel.EntranceExaminationsCheckProtocols.Add(protocol); ApplyProtocolIntoEgeResults(vm, protocol); Session.DataModel.SaveChanges(); RaisePropertyChanged("Protocols"); LogService.WriteLog(string.Format("Добавлен протокол проверки ЕГЭ: №{0} от {1} ({2})", protocol.Number, ((DateTime)protocol.Date).ToString("dd.MM.yyyy г."), protocol.Examination)); } break; } case SelectableEntity.InnerExaminationProtocol: { var vm = new InnerEntranceExaminationProtocolEditorViewModel(protocol); if (DialogLayer.ShowEditor(EditingContent.InnerEntranceExaminationProtocolEditor, vm)) { Session.DataModel.EntranceExaminationsCheckProtocols.Add(protocol); ApplyProtocolIntoInnerResults(vm, protocol); Session.DataModel.SaveChanges(); RaisePropertyChanged("Protocols"); LogService.WriteLog(string.Format("Добавлен протокол проверки ВИ: №{0} от {1} ({2})", protocol.Number, ((DateTime)protocol.Date).ToString("dd.MM.yyyy г."), protocol.Examination)); } break; } default: break; } }