Beispiel #1
0
        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(ParticipantViewModel _participantViewModel)
        {
            if (ModelState.IsValid)
            {
                participantService.Create(_participantViewModel.Participant);
                return(RedirectToAction("Details", "Teams", new { id = _participantViewModel.Participant.TeamId }));
            }
            Team team = teamService.GetById(_participantViewModel.Participant.TeamId);

            _participantViewModel.RankingList = GetRankingList(team.Tournament);
            return(View(_participantViewModel));
        }