Ejemplo n.º 1
0
        public StatisticsResponseModel GetStatistics()
        {
            var totalBikes = this.dbContext
                             .Bikes.Count();

            var totalUsers = this.dbContext
                             .Users.Count();

            var statistics = new StatisticsResponseModel
            {
                TotalBikes = totalBikes,
                TotalUsers = totalUsers,
                TotalRents = 0
            };

            return(statistics);
        }
        public ActionResult <StatisticsResponseModel> Get()
        {
            var registeredUsersArray = new int[12];

            for (int i = 0; i < registeredUsersArray.Length; i++)
            {
                registeredUsersArray[i] = this.usersRepository.All().Where(o => o.CreatedOn.Month == (i + 1)).Count();
            }

            var model = new StatisticsResponseModel()
            {
                recipesCount         = this.recipesRepository.All().Count(),
                articlesCount        = this.articlesRepository.All().Count(),
                reviewedrecipesCount = this.recipesRepository.All().Where(x => x.Reviews.Count >= 0).Count(),
                reviewsCount         = this.reviewsRepository.All().Count(),
                commentsCount        = this.commentsRepository.All().Count(),
            };

            model.registeredUsers = registeredUsersArray;
            return(model);
        }