Пример #1
0
        public JsonResult CreateTeam(vmTeam_Create teamCreate)
        {
            string errors = string.Empty;
            if (ModelState.IsValid)
            {
                if (!_teamService.CheckTeamNameForDirtyWords(teamCreate.TeamName))
                {
                    return Json("The requested team name contains a naughty word.");
                }

                if (_teamService.CheckTeamNameAvailability(teamCreate.EventId, teamCreate.TeamName))
                {
                    var newTeam = new Team { EventId = teamCreate.EventId, Name = teamCreate.TeamName, CreatorID = CurrentUser.UserId};
                    ServiceResult result = _teamService.CreateTeam(newTeam, teamCreate.RegistrationId);
                    if (result.Success)
                    {
                        return Json(new { redirect = Url.Action("ViewTeam", "Team", new { teamId = newTeam.TeamId}) });
                    }
                    result.GetServiceErrors().ForEach(x => errors += x.ErrorMessage + "<br/>");
                    errors += string.Format("\nEventID: {0}, name: {1}, regid: {2}\n", teamCreate.EventId,
                                            teamCreate.TeamName, teamCreate.RegistrationId);
                    return Json(errors);
                }
                return Json("The requested team name is already in use for this event. Please select a different team name.");
            }
            ModelState.Values.ForEach(x => errors += x.Errors + "<br/>");
            return Json(errors);
        }
Пример #2
0
        public ActionResult CreateTeam(int eventId, int registrationId, int teamId)
        {
            var team = (teamId >= 0) ? _teamService.GetTeamById(teamId) : null;

            vmTeam_Create vm = new vmTeam_Create {
                EventId = eventId,
                RegistrationId = registrationId,
                ReturnUrl = Request.UrlReferrer.AbsolutePath,
                CurrentTeam = team
            };

            return View(vm);
        }
Пример #3
0
        public JsonResult VerifyTeamNameAvailability(vmTeam_Create createTeam)
        {
            if (!_teamService.CheckTeamNameForDirtyWords(createTeam.TeamName))
            {
                return Json("The requested team name contains a naughty word.");
            }

            return Json(!_teamService.CheckTeamNameAvailability(createTeam.EventId, createTeam.TeamName) ? "The requested team name is already in use for this event. Please select a different team name." : string.Empty);
        }