public ActionResult <APIMessageResponse> Post([FromBody] FootballTeam _footballTeam) { return(this._fbTeamService.InsertUpdateTeamsInfo(_footballTeam)); }
// Краща команда забиті-пропущені.Пріорітет має команда з більшою кількістю забитих голів public FootballTeam BestScoredMissed() { FootballTeam bestTeam = teams.OrderBy(team => (team.GoalsScored - team.MissedBalls)).ThenBy(team => team.GoalsScored).LastOrDefault(); return(bestTeam); }
public GroupStageMatch(FootballTeam homeTeam, FootballTeam awayTeam, string groupName) : base(homeTeam, awayTeam) { this.groupName = groupName; }
public KnockoutMatch(FootballTeam homeTeam, FootballTeam awayTeam, KnockoutType knockoutType) : base(homeTeam, awayTeam) { this.knockoutType = knockoutType; }
public ChampionshipMatch(FootballTeam homeTeam, FootballTeam awayTeam) : base(homeTeam, awayTeam) { }
public IHttpActionResult LeagueTable(string leagueName) { using (var seasonClient = new HttpClient()) { // I may have to find a way of dynamically changing the season at some point later on seasonClient.BaseAddress = new Uri(apiURL); seasonClient.DefaultRequestHeaders.Accept.Clear(); seasonClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage seasonResponse = seasonClient.GetAsync("v1/soccerseasons/?season=2015").Result; if (seasonResponse.IsSuccessStatusCode) { JArray seasonArray = seasonResponse.Content.ReadAsAsync <JArray>().Result; foreach (JObject seasonObject in seasonArray) { string leagueCode = seasonObject["league"].ToString(); if (leagueCode == leagueName.ToUpper()) { string objectURL = seasonObject["_links"]["leagueTable"]["href"].ToString(); string leagueURL = objectURL.Remove(objectURL.IndexOf(apiURL), apiURL.Length); // I need to make a second http call in order to get the required league object using (var leagueClient = new HttpClient()) { leagueClient.BaseAddress = new Uri(apiURL); leagueClient.DefaultRequestHeaders.Accept.Clear(); leagueClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage leagueResponse = seasonClient.GetAsync(leagueURL).Result; if (leagueResponse.IsSuccessStatusCode) { JObject leagueObject = leagueResponse.Content.ReadAsAsync <JObject>().Result; JArray teamsArray = leagueObject["standing"] as JArray; FootballTeam[] leagueTeams = new FootballTeam[teamsArray.Count]; for (int i = 0; i < teamsArray.Count; i++) { leagueTeams[i] = new FootballTeam { teamName = teamsArray[i]["teamName"].ToString(), leagueRanking = Convert.ToInt32(teamsArray[i]["position"]), points = Convert.ToInt32(teamsArray[i]["playedGames"]), gamesPlayed = Convert.ToInt32(teamsArray[i]["points"]), wins = Convert.ToInt32(teamsArray[i]["wins"]), draws = Convert.ToInt32(teamsArray[i]["draws"]), losses = Convert.ToInt32(teamsArray[i]["losses"]) }; } FootballLeague league = new FootballLeague { leagueName = leagueObject["leagueCaption"].ToString(), matchday = Convert.ToInt32(leagueObject["matchday"]), teams = leagueTeams }; return(Ok(league)); } else { // Something is wrong with the link provided by the API Log.Debug("Retrieved League ID was incorrect. Probably due to change in the third party API"); return(NotFound()); } } } } // Not found compared with user input. Probably user input is wrong Log.Debug("User input must have entered incorrect League ID. Input = " + leagueName); return(NotFound()); } else { // Didn't get any result from their API Log.Debug("Could not establish a connection to the third party API"); return(NotFound()); } } }
private static void AddTeam(string teamName) { var team = new FootballTeam(teamName); footballTeams.Add(teamName, team); }
public string ShowTeamRating(string teamName, FootballTeam team) { return($"{team.Name} - {team.TeamRating}"); }
public void SaveATeam(FootballTeam team) { col.InsertOne(team); }
static async Task <Result> ProcessInsert(Action <IEntity> addEntityToDatabase, Func <Task <int> > saveChangesToDb, FootballTeam footBallTeam) { Func <Task <Result> > proccessAll = async() => { addEntityToDatabase(footBallTeam); return(await SaveChangesToDb(saveChangesToDb)); }; return(await ProcessDbSaveFunctions(proccessAll)); }
static async Task <Result> ProcessUpdate(Action <IEntity> addToUpdateDb, Func <Task <int> > saveChangesToDb, FootballTeam footballTeam) { Func <Task <Result> > proccessAll = async() => { AttachToDbByUpdate(addToUpdateDb, footballTeam); var r = await saveChangesToDb(); return(Result.Ok()); }; return(await ProcessDbSaveFunctions(proccessAll)); }
public static async Task <Result> Insert(ResumeBackgroundServiceDbContext db, FootballTeam footballTeam) { return(await ProcessInsert(e => db.Add(e), async() => await db.SaveChangesAsync(), footballTeam)); }
public static async Task <Result> Update(ResumeDbContext db, FootballTeam footballTeam) { return(await ProcessUpdate(e => db.Update(e), async() => await db.SaveChangesAsync(), footballTeam)); }
public static async Task <Result> Update(ResumeBackgroundServiceDbContext db, FootballTeam footballTeam) { try { return(await ProcessUpdate(e => { db.Attach(e); db.Update(e); }, async() => await db.SaveChangesAsync(), footballTeam)); } catch (Exception ex) { throw; } }
private String RespondToGameScore(IFootballSensor sensor, FootballTeam team) { FootballGame score = sensor.LoadLatestScoreForTeam(team.Key); if (score == null) { return(String.Format("The {0} are not playing this week.", team.Name)); } String startingPhrase = String.Empty; switch (score.State) { case GameState.Started: if (score.WinningTeamScore.Score == score.LosingTeamScore.Score) { if (score.WinningTeamScore.Team.Equals(team)) { startingPhrase = String.Format("The {0} and the {1} are tied at {2} a piece. ", team.Name, score.LosingTeamScore.Team.Name, score.WinningTeamScore.Score); } else { startingPhrase = String.Format("The {0} and the {1} are tied at {2} a piece. ", team.Name, score.WinningTeamScore.Team.Name, score.WinningTeamScore.Score); } } else if (score.WinningTeamScore.Team.Equals(team)) { startingPhrase = String.Format("The {0} are beating the {1} by a score of {2} to {3}. ", team.Name, score.LosingTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score); } else { startingPhrase = String.Format("The {0} are losing to the {1} by a score of {2} to {3}. ", team.Name, score.WinningTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score); } String quarterNum = SayOrdinal(score.Quarter); if (score.TimeLeft.Equals(TimeSpan.Zero)) { startingPhrase += String.Format("at the end of the {0} quarter.", quarterNum); } else if (score.TimeLeft.Equals(new TimeSpan(0, 15, 0))) { startingPhrase += String.Format("at the beginning of the {0} quarter.", quarterNum); } else { startingPhrase += String.Format("with {0} {1} remaining in the {2} quarter.", score.TimeLeft.Minutes, score.TimeLeft.Seconds, quarterNum); } break; case GameState.GameHasntStarted: if (score.HomeTeamScore.Team.Equals(team)) { startingPhrase = String.Format("The {0} will be playing the {1} at {2} on {3}.", team.Name, score.AwayTeamScore.Team.Name, score.StartingTime.ToShortTimeString(), score.StartingTime.DayOfWeek.ToString()); } else { startingPhrase = String.Format("The {0} will be playing the {1} at {2} on {3}.", team.Name, score.HomeTeamScore.Team.Name, score.StartingTime.ToShortTimeString(), score.StartingTime.DayOfWeek.ToString()); } break; case GameState.Completed: if (score.WinningTeamScore.Team.Equals(team)) { startingPhrase = String.Format("The {0} beat the {1} by a score of {2} to {3}.", team.Name, score.LosingTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score); } else { startingPhrase = String.Format("The {0} lost to the {1} by a score of {2} to {3}.", team.Name, score.WinningTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score); } break; } return(startingPhrase); }
public FootballCommand(FootballTeam teamSet) { team = teamSet; }