C# Class ActivEarth.Server.Service.Competition.ContestManager

显示文件 Open project: mlcamilli/ActivEarth

Public Methods

Method Description
AddGroup ( int contestId, Group group ) : bool

Adds a group to a group Contest; will fail if a group is added to an individual contest.

AddUser ( int contestId, User user ) : void

Adds a user to the Contest.

CalculateContestReward ( int days, int teams ) : int

Calculates the reward for a time-based contest.

CleanUp ( ) : void

Cleans up the contest list, deactivating expired time-based contests and deleting deactivated contests that have reached the end of their retainment period.

CreateContest ( ContestType type, string name, string description, System.DateTime start, System.DateTime end, bool searchable, Statistic statistic, int creatorId ) : int

Creates a new time-based Contest

CreateContest ( ContestType type, string name, string description, System.DateTime start, float end, bool searchable, Statistic statistic, int creatorId ) : int

Creates a new goal-based Contest

DistributeContestReward ( int contestId ) : void

Distributes the ActivityScore reward for a contest and deactivates it.

GetContest ( int id, bool loadTeams, bool loadTeamMembers ) : Contest

Retrieves a Contest based on its ID.

GetTeamsToDisplay ( ContestTeam userTeam, Contest contest ) : List

Finds the list of teams that should be displayed to the user as part of the contest standings report. For the user's current bracket, the user's team will be shown. For brackets better than the user's current standing, the lowest team in the bracket is shown (the team that the user needs to pass to enter that bracket). For brackets worse than the user's current standing, the top team in the bracket is shown (the team that the user needs to stay ahead of to avoid falling into that bracket).

LockContest ( int contestId ) : void

Locks competitor initial values such that the calculation of deltas can begin (to calculate team scores).

RemoveGroup ( int contestId, Group group ) : bool

Removes a group from a Contest.

RemoveUser ( int contestId, User user ) : bool

Adds a user to the Contest.

UpdateTeamScore ( int teamId ) : void
UserCompetingInContest ( int userId, int contestId ) : bool

Queries the DB to see if a user is registered for a particular contest.

Private Methods

Method Description
CalculateEstimatedLengthInDays ( Contest contest ) : int

Returns the length of a contest of a time-based contest, and estimates the length of a goal-based contest.

ContestManager ( ) : System

Private constructor, can not instantiate.

Method Details

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

AddUser() public static method

Adds a user to the Contest.
public static AddUser ( int contestId, User user ) : void
contestId int
user ActivEarth.Objects.Profile.User User to be added.
return void

CalculateContestReward() public static method

Calculates the reward for a time-based contest.
public static CalculateContestReward ( int days, int teams ) : int
days int Duration of the contest, in days.
teams int Number of teams competing in the contest.
return int

CleanUp() public static method

Cleans up the contest list, deactivating expired time-based contests and deleting deactivated contests that have reached the end of their retainment period.
public static CleanUp ( ) : void
return void

CreateContest() public static method

Creates a new time-based Contest
public static CreateContest ( ContestType type, string name, string description, System.DateTime start, System.DateTime end, bool searchable, Statistic statistic, int creatorId ) : int
type ContestType Determines whether the contest in Individual or Group-based.
name string Contest Name.
description string Contest Description.
start System.DateTime Time to start the contest.
end System.DateTime Time to end the contest.
searchable bool True if the Contest can be found by searching (public), false if private.
statistic Statistic Statistic on which the Contest is based.
creatorId int UserID of the creator of the contest.
return int

CreateContest() public static method

Creates a new goal-based Contest
public static CreateContest ( ContestType type, string name, string description, System.DateTime start, float end, bool searchable, Statistic statistic, int creatorId ) : int
type ContestType Determines whether the contest in Individual or Group-based.
name string Contest Name.
description string Contest Description.
start System.DateTime Time to start the contest.
end float Score at which to end the contest.
searchable bool True if the Contest can be found by searching (public), false if private.
statistic Statistic Statistic on which the Contest is based.
creatorId int UserID of the creator of the contest.
return int

DistributeContestReward() public static method

Distributes the ActivityScore reward for a contest and deactivates it.
public static DistributeContestReward ( int contestId ) : void
contestId int ID of the contest to process.
return void

GetContest() public static method

Retrieves a Contest based on its ID.
public static GetContest ( int id, bool loadTeams, bool loadTeamMembers ) : Contest
id int ID of the Contest to be retrieved.
loadTeams bool
loadTeamMembers bool
return ActivEarth.Objects.Competition.Contests.Contest

GetTeamsToDisplay() public static method

Finds the list of teams that should be displayed to the user as part of the contest standings report. For the user's current bracket, the user's team will be shown. For brackets better than the user's current standing, the lowest team in the bracket is shown (the team that the user needs to pass to enter that bracket). For brackets worse than the user's current standing, the top team in the bracket is shown (the team that the user needs to stay ahead of to avoid falling into that bracket).
public static GetTeamsToDisplay ( ContestTeam userTeam, Contest contest ) : List
userTeam ActivEarth.Objects.Competition.Contests.ContestTeam Team that the current user is on.
contest ActivEarth.Objects.Competition.Contests.Contest Contest to be analyzed.
return List

LockContest() public static method

Locks competitor initial values such that the calculation of deltas can begin (to calculate team scores).
public static LockContest ( int contestId ) : void
contestId int
return void

RemoveGroup() public static method

Removes a group from a Contest.
public static RemoveGroup ( int contestId, Group group ) : bool
contestId int ID for the contest the group should be removed from.
group ActivEarth.Objects.Groups.Group Group to be removed.
return bool

RemoveUser() public static method

Adds a user to the Contest.
public static RemoveUser ( int contestId, User user ) : bool
contestId int
user ActivEarth.Objects.Profile.User User to be added.
return bool

UpdateTeamScore() public static method

public static UpdateTeamScore ( int teamId ) : void
teamId int
return void

UserCompetingInContest() public static method

Queries the DB to see if a user is registered for a particular contest.
public static UserCompetingInContest ( int userId, int contestId ) : bool
userId int ID of the user.
contestId int ID of the contest to query.
return bool