public UIElement GetDisplayElement() { ParticipantListViewModel viewModel = new ParticipantListViewModel(this, facade); ParticipantListControl control = new ParticipantListControl(viewModel); viewModel.ParticipantSelected += (s, e) => { DataServiceMessage <IEnumerable <string> > countryServiceMessage; DataServiceMessage <IEnumerable <string> > sportServiceMessage; using (ICountryService service = factory.CreateCountryService()) { countryServiceMessage = service.GetAll(); RaiseReceivedMessageEvent(countryServiceMessage.IsSuccessful, countryServiceMessage.Message); } using (ISportService service = factory.CreateSportService()) { sportServiceMessage = service.GetAll(); RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message); } if (countryServiceMessage.IsSuccessful && sportServiceMessage.IsSuccessful) { var countries = countryServiceMessage.Data; var sports = sportServiceMessage.Data; Edit(e.Participant, countries, sports); } }; viewModel.ParticipantDeleteRequest += (s, e) => Delete(e.Participant); return(control); }
public ActionResult Create() { ParticipantListViewModel participantListViewModel = new ParticipantListViewModel(); participantListViewModel.ParticipantList = participantList; ParticipantCreateViewModel model = new ParticipantCreateViewModel { Participant = new ParticipantViewModel(), ParticipantList = participantListViewModel }; return(View(model)); }
public ParticipantListControl(ParticipantListViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; }