Example #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);
        }
Example #2
0
        public ActionResult Create()
        {
            ParticipantListViewModel participantListViewModel = new ParticipantListViewModel();

            participantListViewModel.ParticipantList = participantList;
            ParticipantCreateViewModel model = new ParticipantCreateViewModel
            {
                Participant     = new ParticipantViewModel(),
                ParticipantList = participantListViewModel
            };

            return(View(model));
        }
Example #3
0
        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"));
        }
Example #4
0
 public ParticipantCreateControl(ParticipantCreateViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }