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

Afficher le fichier Open project: mlcamilli/ActivEarth

Méthodes publiques

Méthode 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

Méthode 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 méthode

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.
Résultat bool

AddUser() public static méthode

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.
Résultat void

CalculateContestReward() public static méthode

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.
Résultat int

CleanUp() public static méthode

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
Résultat void

CreateContest() public static méthode

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.
Résultat int

CreateContest() public static méthode

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.
Résultat int

DistributeContestReward() public static méthode

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

GetContest() public static méthode

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
Résultat ActivEarth.Objects.Competition.Contests.Contest

GetTeamsToDisplay() public static méthode

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.
Résultat List

LockContest() public static méthode

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

RemoveGroup() public static méthode

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.
Résultat bool

RemoveUser() public static méthode

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.
Résultat bool

UpdateTeamScore() public static méthode

public static UpdateTeamScore ( int teamId ) : void
teamId int
Résultat void

UserCompetingInContest() public static méthode

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.
Résultat bool