Esempio n. 1
0
        public ActionResult <StatsModel> GetBaseStats()
        {
            var statsToBeReturn = new StatsModel();

            statsToBeReturn.TripsStats.TripsCount = _statsRepository.GetTripsCountForUser(_userInfoService.UserId);

            statsToBeReturn.FlightsStats.FlightsCount   = _statsRepository.GetFlightsCountForUser(_userInfoService.UserId);
            statsToBeReturn.FlightsStats.FligtsDistance = _statsRepository.GetFlightsDistanceForUser(_userInfoService.UserId);
            statsToBeReturn.FlightsStats.FlightsTime    = _statsRepository.GetFlightsTimeForUser(_userInfoService.UserId);

            statsToBeReturn.CountriesStats.VisitedCountriesCount = _statsRepository.GetCountriesForUser(_userInfoService.UserId);

            return(Ok(statsToBeReturn));
        }
Esempio n. 2
0
        public async Task <ActionResult <UserWithStatsModel> > GetUsersWithStats(string id)
        {
            var userFromRepo = await _repository.GetUserByIdAsync(id);

            if (userFromRepo == null)
            {
                return(NotFound());
            }

            var userWithStats = _mapper.Map <UserWithStatsModel>(userFromRepo);

            userWithStats.UserStats.UserFlightsCount     = _statsRepository.GetFlightsCountForUser(id);
            userWithStats.UserStats.FlightsDistance      = _statsRepository.GetFlightsDistanceForUser(id);
            userWithStats.UserStats.FlightsTime          = _statsRepository.GetFlightsTimeForUser(id);
            userWithStats.UserStats.FlightsTime          = _statsRepository.GetFlightsTimeForUser(id);
            userWithStats.UserStats.AirportsCount        = _statsRepository.GetAirportsCountForUser(id);
            userWithStats.UserStats.AirportsCountryCount = _statsRepository.GetAirportsCountryCountForUser(id);

            return(Ok(userWithStats));
        }