ActivEarth.Server.Service.Competition.ContestManager.AddGroup C# (CSharp) Method

AddGroup() public static method

Adds a group to a group Contest; will fail if a group is added to an individual contest.
public static AddGroup ( int contestId, Group group ) : bool
contestId int ID for the contest the group should be added to.
group ActivEarth.Objects.Groups.Group Group to be added.
return bool
        public static bool AddGroup(int contestId, Group group)
        {
            Contest contest = ContestDAO.GetContestFromContestId(contestId, false, false);

            if (contest.Type == ContestType.Group)
            {
                string teamName = group.Name;

                ContestTeam newTeam = new ContestTeam
                {
                    ContestId = contestId,
                    Name = teamName,
                    GroupId = group.ID
                };

                int teamId = TeamDAO.CreateNewTeam(newTeam);

                foreach (User user in group.Members)
                {
                    TeamDAO.CreateNewTeamMember(user.UserID, teamId);
                }

                contest.Reward = ContestManager.CalculateContestReward(
                    ContestManager.CalculateEstimatedLengthInDays(contest),
                    TeamDAO.GetTeamsFromContestId(contestId, false).Count);
                ContestDAO.UpdateContest(contest);

                return (teamId > 0);
            }
            else
            {
                return false;
            }
        }