public JsonResult GetLocations(int currentPage = 1, string country = "All")
        {
            country = country.Trim();
            var locations = country == "All" ? _weatherRepo.Get() : _weatherRepo.Get(c => c.Country.Equals(country));

            int pages = locations.Count() / PageSize;
            int count = locations.Count() % PageSize == 0 ? pages : ++pages;

            locations = locations.Skip((currentPage - 1) * PageSize).Take(PageSize).ToList();

            return(Json(new { locations = locations, allPages = count, currentPage = currentPage }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public async Task <GetResponse> Handle(GetRequest request, CancellationToken cancellationToken)
        {
            var currentWeather = await _repository.Get(request);

            return(_mapper.Map <GetResponse>(currentWeather));
        }
Beispiel #3
0
 public WeatherForecast Get(Guid id)
 {
     return(repository.Get(id));
 }
 public async Task <IEnumerable <ForecastViewModel> > Get(int days)
 {
     return((await _repository.Get(days)).ToViewModel());
 }
 public MyWeatherData Get()
 {
     return(weatherRepo.Get());
 }