public IActionResult GetCitiesForMonth(Guid monthId) { if (!_monthRepository.EntityExists(monthId)) { return(NotFound()); } var citiesForMonthFromRepo = _monthRepository.GetCitiesForMonth(monthId); var results = Mapper.Map <IEnumerable <CityApiModel> >(citiesForMonthFromRepo); return(Ok(results)); }
public IActionResult GetMonths() { var monthsFromRepo = _monthRepository.GetMonths(); var monthsApiModel = Mapper.Map <IEnumerable <MonthApiModel> >(monthsFromRepo); foreach (var monthApiModel in monthsApiModel) { var citiesFromRepo = _monthRepository.GetCitiesForMonth(monthApiModel.Id).Take(5); foreach (var city in citiesFromRepo) { var cityApiModel = Mapper.Map <CityApiModel>(city); cityApiModel.MainImageId = _imageRepository.GetMainImageIdForCity(city.Id); monthApiModel.TopCities.Add(cityApiModel); } } return(Ok(monthsApiModel)); }