Esempio n. 1
0
        public HttpResponseMessage AddMath(Match match)
        {
            User           currentUser = userBusiness.GetUserByExternalId(User.Identity.GetUserId()).Data;
            Result <Match> res         = matchBusiness.AddMatch(currentUser.UserID, match);

            if (res.Success && res.Data.Status == MatchStatus.Confirmed)
            {
                int   totalMatches = matchBusiness.TotalMatchesByStatus(MatchStatus.Confirmed);
                Match m            = matchBusiness.GetMatchById(match.MatchID).Data;
                if (m != null)
                {
                    matchBusiness.LoadScores(m);
                    match.Game = gameBusiness.GetById(match.GameID).Data;
                }
                LiveScores.Instance.BroadcastTotalMatches(m, totalMatches);
            }

            HttpResponseMessage response = res.Success ?
                                           Request.CreateResponse(HttpStatusCode.Created, res.Data) :
                                           Request.CreateResponse(HttpStatusCode.InternalServerError, res.Message);

            return(response);
        }