public string AddLocation(string locationname) { return(_locationService.Create(new Location { Name = locationname, AddDate = DateTime.Now })); }
public string AddUmpire(string umpirename) { return(_umpireService.Create(new Umpire { Name = umpirename, AddDate = DateTime.Now })); }
public string AddTeam(string teamName) { var newteam = _teamService.Create(new Team { Name = teamName, AddDate = DateTime.Today }); return(newteam); }
public string AddTournament(string tournamentName) { var newtournament = _tournamentService.Create(new Tournament { Name = tournamentName, Status = "Open", StartDate = DateTime.Today }); return(newtournament); }
public BatsmanStatisticsPageTest() { Client = new TestClient(); PlayerInningService = new DataSeedService <PlayerInning>(Client); var homeplayerinningId = PlayerInningService.Create(new PlayerInning { PlayerName = "PlayerName", }, new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("matchId", "MatchId"), new KeyValuePair <string, string>("tournamentId", "TournamentId"), new KeyValuePair <string, string>("teamId", "TeamId"), new KeyValuePair <string, string>("playerId", "TeamId:PlayerName") }); }
public string AddAccess(string tournamentId, AccessType accessType) { var tournamentaccess = _accessService.Create(new Access { DocumentType = nameof(Tournament), Documents = new List <DocumentReference> { new DocumentReference { AccessType = accessType, Id = tournamentId } } }); return(tournamentaccess); }
public Match AddMatch(string hometeamid, string awayteamid, string oversOrTournamentId, string location, string primaryumpire, string secondaryumpire) { var hometeam = _teamService.GetItem(hometeamid); if (hometeam == null) { throw new NullReferenceException("Home team name is not added"); } var awayteam = _teamService.GetItem(awayteamid); if (awayteam == null) { throw new NullReferenceException("Away team name is not added"); } int overs; string tournamentId = string.Empty; if (_isTournament) { tournamentId = oversOrTournamentId; overs = _tournamentService.GetItem(tournamentId).TotalOvers; } else { overs = int.Parse(oversOrTournamentId); } var match = new Match { HomeTeam = new TeamInning(), AddDate = DateTime.Now, AwayTeam = new TeamInning(), Location = location, PrimaryUmpire = primaryumpire, SecondaryUmpire = secondaryumpire, TotalOvers = overs }; var matchId = _matchService.Create(match); var matchIdKey = new KeyValuePair <string, string>("matchId", matchId); var tournamentIdKey = new KeyValuePair <string, string>("tournamentId", tournamentId); // Creating team innings and player innings and update match var teamInningService = new DataSeedService <TeamInning>(_client); var playerInningService = new DataSeedService <PlayerInning>(_client); var hometeaminningId = teamInningService.Create(new TeamInning { TeamName = hometeam.Name, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", hometeam.Id) }); foreach (var homeplayername in hometeam.Players) { var homeplayerinningId = playerInningService.Create(new PlayerInning { PlayerName = homeplayername, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", hometeam.Id), new KeyValuePair <string, string>("playerId", $"{hometeam.Id}:{homeplayername}") }); } var awayteaminningId = teamInningService.Create(new TeamInning { TeamName = awayteam.Name, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", awayteam.Id) }); foreach (var awayplayername in awayteam.Players) { var awayplayerinningId = playerInningService.Create(new PlayerInning { PlayerName = awayplayername, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", awayteam.Id), new KeyValuePair <string, string>("playerId", $"{awayteam.Id}:{awayplayername}") }); } //Update Match var updatematch = _matchService.GetItem(matchId); updatematch.HomeTeam = teamInningService.GetItem(hometeaminningId); updatematch.AwayTeam = teamInningService.GetItem(awayteaminningId); _matchService.Update(matchId, updatematch); return(updatematch); }