private UIElement Create(IEnumerable <string> countries, IEnumerable <string> sports) { ParticipantCreateViewModel viewModel = new ParticipantCreateViewModel(countries, sports); ParticipantCreateControl control = new ParticipantCreateControl(viewModel); viewModel.ParticipantCreated += (s, e) => { ParticipantBaseModel participantModel = e.Participant; ParticipantBaseDTO participantDTO = Mapper.Map <ParticipantBaseModel, ParticipantBaseDTO>(participantModel); using (IParticipantService service = factory.CreateParticipantService()) { ServiceMessage serviceMessage = service.Create(participantDTO); RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message); if (serviceMessage.IsSuccessful) { Notify(); viewModel.ParticipantName = String.Empty; } } }; 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 ActionResult Create(ParticipantCreateViewModel _model) { if (participantList.Count > 0) { _model.Participant.Id = participantList.Max(x => x.Id) + 1; } else { _model.Participant.Id = 1; } participantList.Add(_model.Participant); return(RedirectToAction("Index")); }
public ParticipantCreateControl(ParticipantCreateViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; }