Ejemplo n.º 1
0
        public ActionResult Register()
        {
            var teams = teamTasks.GetAll();

            var model = new RegistrationViewModel
            {
                Teams = teams
                            .ToList()
                            .Select(x => new SelectListItem
                            {
                                Text = x.Name,
                                Value = x.Id.ToString()
                            })
            };

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Register(RegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var team = teamTasks.LoadById(model.SelectedTeamId);
                var player = Mapper.Map<Player>(model);
                player.Team = team;

                var registeredPlayer = playerTasks.Register(player);

                if (registeredPlayer != null)
                {
                    formsAuthentication.SignIn(model.Username, false);

                    return RedirectToAction("Index", "MiniLeague");
                }
                else
                {
                    ModelState.AddModelError("", "The registration details provided are incorrect.");
                }
            }

            return View(model);
        }