예제 #1
0
        /// <summary>
        /// Validates a team on the server
        /// before adding a new record or updating an existing record.
        /// </summary>
        /// <param name="team">The team to validate.</param>
        private void ValidateTeam(Team team)
        {
            if (team.Event.Teams.Count() >= team.Event.TeamLimit)
            {
                TempData["Error"] = "You can't add more teams, the event is full!";
            }

            // If there aren't any "EventId" and "TeamName" field validation errors...
            if (ModelState.IsValidField("Team.EventId") &&
                ModelState.IsValidField("Team.TeamName"))
            {
                // Then make sure that the provided team name is unique for the provided event.
                // TODO Call method to check if the issue number is available for this team.
                if (_teamsRepository.TeamEventHasName(team.Id, team.EventId, team.TeamName))
                {
                    ModelState.AddModelError("Team.TeamName",
                                             "The provided Issue Number has already been entered for the selected Event.");
                }
            }
        }