private void EditSport(string sportName) { SportEditViewModel viewModel = new SportEditViewModel(sportName); SportEditControl control = new SportEditControl(viewModel); Window window = WindowFactory.CreateByContentsSize(control); viewModel.SportEdited += (s, e) => { SportEditModel sportEditModel = e.Sport; SportEditDTO sportEditDTO = Mapper.Map <SportEditModel, SportEditDTO>(sportEditModel); using (ISportService service = factory.CreateSportService()) { ServiceMessage serviceMessage = service.Update(sportEditDTO); RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message); if (serviceMessage.IsSuccessful) { window.Close(); Notify(); } } }; window.Show(); }
public SportEditControl(SportEditViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; }