Exemplo n.º 1
0
        public HttpResponseMessage GetStats()
        {
            Playground.Model.ViewModel.PlaygroundStats res = new Model.ViewModel.PlaygroundStats()
            {
                TotalPlaygrounds = playgroundBusiness.TotalPlaygroundsCound(),
                TotalGames       = gameBusiness.TotalGamesCount(),
                TotalUsers       = userBusiness.TotalUsersCount(),
                TotalPlayers     = competitorBusiness.TotalCompetitorsCount(),
                TotalMatches     = matchBusiness.TotalMatchesByStatus(MatchStatus.Confirmed)
            };


            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res);

            return(response);
        }
Exemplo n.º 2
0
        public Result <Playground.Model.ViewModel.PlaygroundStats> GetStats(int playgroundID)
        {
            Result <Playground.Model.ViewModel.PlaygroundStats> retVal = null;

            try
            {
                int totalGames = Uow.PlaygroundGames
                                 .GetAll()
                                 .Where(pgg => pgg.PlaygroundID == playgroundID)
                                 .Count();

                int totalUsers = Uow.PlaygroundUsers
                                 .GetAll()
                                 .Where(pgu => pgu.PlaygroundID == playgroundID)
                                 .Count();

                int totalMatches = Uow.Matches
                                   .GetAll()
                                   .Where(m => m.PlaygroundID == playgroundID)
                                   .Count();

                Playground.Model.ViewModel.PlaygroundStats result = new Model.ViewModel.PlaygroundStats()
                {
                    TotalGames   = totalGames,
                    TotalUsers   = totalUsers,
                    TotalMatches = totalMatches
                };

                retVal = ResultHandler <Playground.Model.ViewModel.PlaygroundStats> .Sucess(result);
            }
            catch (Exception ex)
            {
                log.Error(String.Format("Erorr loading playground stats. PlaygroundID : {0}", playgroundID), ex);
                retVal = ResultHandler <Playground.Model.ViewModel.PlaygroundStats> .Erorr("Erorr loading playground stats.");
            }

            return(retVal);
        }