public HttpResponseMessage GetStats(int id) { Result <Game> gameRes = gameBusiness.GetById(id); GameStats stats = null; if (gameRes.Success) { gameRes.Data.Category = gameCategoryBusiness.GetById(gameRes.Data.GameCategoryID).Data; stats = new GameStats(gameRes.Data); stats.TotalCompetitors = gameBusiness.TotalCompetitorsCount(stats.GameID); stats.TotalMatches = gameBusiness.TotalMatchesCount(stats.GameID); } HttpResponseMessage response = gameRes.Success ? Request.CreateResponse(HttpStatusCode.OK, stats) : Request.CreateResponse(HttpStatusCode.InternalServerError, gameRes.Message); return(response); }
public HttpResponseMessage ConfirmScore(CompetitorScore competitorScore) { Result <bool> res = competitorBusiness.ConfirmScore(competitorScore); if (res.Success && res.Data) { int totalMatches = matchBusiness.TotalMatchesByStatus(MatchStatus.Confirmed); Match match = matchBusiness.GetMatchById(competitorScore.MatchID).Data; if (match != null) { matchBusiness.LoadScores(match); match.Game = gameBusiness.GetById(match.GameID).Data; } LiveScores.Instance.BroadcastTotalMatches(match, totalMatches); } HttpResponseMessage response = res.Success ? Request.CreateResponse(HttpStatusCode.OK) : Request.CreateResponse(HttpStatusCode.InternalServerError, "Error confirming score"); return(response); }