C# Class ActivEarth.DAO.TeamDAO

显示文件 Open project: mlcamilli/ActivEarth

Public Methods

Method Description
CreateNewTeam ( ContestTeam team ) : int

Saves a Team as a new entry in the DB.

CreateNewTeamMember ( ContestTeamMember teamMember, int teamId ) : int

Creates a new DB entry for a team member.

CreateNewTeamMember ( int userId, int teamId ) : int

Creates a new DB entry for a team member.

GetCompetitorCount ( int contestId ) : int

Retrieves the number of competitors for a contest.

GetTeamFromTeamId ( int teamId, bool loadMembers ) : ContestTeam

Retrieves a Team from the DB based on its ID.

GetTeamFromUserIdAndContestId ( int userId, int contestId, bool loadMembers ) : ContestTeam

Retrieves the team from a given contest which contains a given member.

GetTeamIdsFromGroupId ( int groupId ) : List

Retrieves all team IDs which match the provided group.

GetTeamIdsFromUserId ( int userId ) : List

Retrieves all team IDs of which the provided user is a member.

GetTeamMembersFromTeamId ( int teamId ) : List

Retrieves the list of team members for a particular team.

GetTeamsFromContestId ( int contestId, bool loadMembers ) : List

Retrieves all teams competing in a particular contest.

LockTeam ( ContestTeam team ) : void

Notes each user's state at the beginning of a contest so that the delta score can be calculated. Sets the initialized flag to true, allowing the calculation of delta scores.

RemoveTeam ( int teamId ) : bool

Removes an existing Team from the DB.

RemoveTeamMemberFromUserIdAndContestId ( int userId, int contestId ) : bool

Removes a team member DB entry.

RemoveTeamMembersFromTeamId ( int teamId ) : bool

Removes all team member entries pertaining to a given team.

UpdateTeam ( ContestTeam team ) : bool

Updates an existing Team in the DB.

UpdateTeamMembers ( ContestTeam team ) : bool

Updates the entry of any members already existing on the team, and creates new entries for new members of the team.

UpdateTeamScore ( int teamId ) : void

Recalculates and updates the team's contest score.

UserCompetingInContest ( int userId, int contestId ) : bool

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

Private Methods

Method Description
CalculateUserScore ( int userId, float initial, Statistic statistic ) : float

Calculates the user's change in the relevant statistic since the beginning of the contest; their 'score' for the contest.

GetContestIdFromTeamId ( int teamId ) : int

Retrieves the contest ID for the contest that a team is participating in.

Method Details

CreateNewTeam() public static method

Saves a Team as a new entry in the DB.
public static CreateNewTeam ( ContestTeam team ) : int
team ActivEarth.Objects.Competition.Contests.ContestTeam Team object to add to the DB.
return int

CreateNewTeamMember() public static method

Creates a new DB entry for a team member.
public static CreateNewTeamMember ( ContestTeamMember teamMember, int teamId ) : int
teamMember ActivEarth.Objects.Competition.Contests.ContestTeamMember Member to be added to the DB.
teamId int Team ID that the member should be added to.
return int

CreateNewTeamMember() public static method

Creates a new DB entry for a team member.
public static CreateNewTeamMember ( int userId, int teamId ) : int
userId int ID of the Member to be added to the DB.
teamId int Team ID that the member should be added to.
return int

GetCompetitorCount() public static method

Retrieves the number of competitors for a contest.
public static GetCompetitorCount ( int contestId ) : int
contestId int ID of the contest.
return int

GetTeamFromTeamId() public static method

Retrieves a Team from the DB based on its ID.
public static GetTeamFromTeamId ( int teamId, bool loadMembers ) : ContestTeam
teamId int Identifier of the team to retrieve.
loadMembers bool Indicates whether or not the team member list should be populated.
return ActivEarth.Objects.Competition.Contests.ContestTeam

GetTeamFromUserIdAndContestId() public static method

Retrieves the team from a given contest which contains a given member.
public static GetTeamFromUserIdAndContestId ( int userId, int contestId, bool loadMembers ) : ContestTeam
userId int ID of the user to match the team to.
contestId int ID of the contest to match the team to.
loadMembers bool Indicates whether or not the team member lists should be populated.
return ActivEarth.Objects.Competition.Contests.ContestTeam

GetTeamIdsFromGroupId() public static method

Retrieves all team IDs which match the provided group.
public static GetTeamIdsFromGroupId ( int groupId ) : List
groupId int
return List

GetTeamIdsFromUserId() public static method

Retrieves all team IDs of which the provided user is a member.
public static GetTeamIdsFromUserId ( int userId ) : List
userId int
return List

GetTeamMembersFromTeamId() public static method

Retrieves the list of team members for a particular team.
public static GetTeamMembersFromTeamId ( int teamId ) : List
teamId int Team ID to retrieve the members for.
return List

GetTeamsFromContestId() public static method

Retrieves all teams competing in a particular contest.
public static GetTeamsFromContestId ( int contestId, bool loadMembers ) : List
contestId int ID of the contest to load teams for.
loadMembers bool Indicates whether or not the team member lists should be populated.
return List

LockTeam() public static method

Notes each user's state at the beginning of a contest so that the delta score can be calculated. Sets the initialized flag to true, allowing the calculation of delta scores.
public static LockTeam ( ContestTeam team ) : void
team ActivEarth.Objects.Competition.Contests.ContestTeam
return void

RemoveTeam() public static method

Removes an existing Team from the DB.
public static RemoveTeam ( int teamId ) : bool
teamId int
return bool

RemoveTeamMemberFromUserIdAndContestId() public static method

Removes a team member DB entry.
public static RemoveTeamMemberFromUserIdAndContestId ( int userId, int contestId ) : bool
userId int User to remove.
contestId int Contest to remove the user from.
return bool

RemoveTeamMembersFromTeamId() public static method

Removes all team member entries pertaining to a given team.
public static RemoveTeamMembersFromTeamId ( int teamId ) : bool
teamId int Team to remove the members from.
return bool

UpdateTeam() public static method

Updates an existing Team in the DB.
public static UpdateTeam ( ContestTeam team ) : bool
team ActivEarth.Objects.Competition.Contests.ContestTeam Team whose record needs updating.
return bool

UpdateTeamMembers() public static method

Updates the entry of any members already existing on the team, and creates new entries for new members of the team.
public static UpdateTeamMembers ( ContestTeam team ) : bool
team ActivEarth.Objects.Competition.Contests.ContestTeam Team whose members must be updated.
return bool

UpdateTeamScore() public static method

Recalculates and updates the team's contest score.
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