private void Edit(ParticipantDisplayModel participantDisplayModel, IEnumerable <string> countries, IEnumerable <string> sports) { ParticipantInfoViewModel viewModel = new ParticipantInfoViewModel(participantDisplayModel, sports, countries); ParticipantInfoControl control = new ParticipantInfoControl(viewModel); Window window = WindowFactory.CreateByContentsSize(control); viewModel.ParticipantEdited += (s, e) => { ParticipantEditModel participantEditModel = e.Participant; ParticipantEditDTO participantEditDTO = Mapper.Map <ParticipantEditModel, ParticipantEditDTO>(participantEditModel); using (IParticipantService service = factory.CreateParticipantService()) { ServiceMessage serviceMessage = service.Update(participantEditDTO); RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message); if (serviceMessage.IsSuccessful) { window.Close(); Notify(); } } }; window.Show(); }
private void RaiseParticipantDeleteRequestEvent(ParticipantDisplayModel participant) { var handler = ParticipantDeleteRequest; if (handler != null) { ParticipantDisplayEventArgs e = new ParticipantDisplayEventArgs(participant); handler(this, e); } }
public ParticipantInfoViewModel(ParticipantDisplayModel participant, IEnumerable <string> sports, IEnumerable <string> countries) { this.participant = new ParticipantEditModel { Name = participant.Name, NewParticipantName = participant.Name, CountryName = participant.CountryName, SportName = participant.SportName, }; this.Sports = new ObservableCollection <string>(sports); this.Countries = new ObservableCollection <string>(countries); this.SaveParticipantCommand = new DelegateCommand(() => RaiseParticipantEditedEvent(this.participant), CanSave); this.UndoCommand = new DelegateCommand(() => Undo(), IsDirty); }
public ParticipantDisplayEventArgs(ParticipantDisplayModel participant) { this.Participant = participant; }