public async Task <IActionResult> GetCitiesPaginationPartial(int pageNumber = 1, int numberOfEntitiesOnPage = 25) { // using REST //var citiesPagination = await _cityClient.GetCitiesPagination(pageNumber, numberOfEntitiesOnPage); //using gRPC (unary) var citiesPaginationReply = await _citiesClient.GetCitiesPagination(pageNumber, numberOfEntitiesOnPage); //using gRPC (stream from server) //var citiesPagination = await _cityClient.GetCitiesPagination(pageNumber, numberOfEntitiesOnPage); //var foo = new List<CityReply>(); //await foreach (var cityReply in _citiesClient.GetCitiesStream(pageNumber, numberOfEntitiesOnPage)) //{ // foo.Add(cityReply); //} CitiesPaginationPartialVM vm = new() { Cities = citiesPaginationReply?.Cities?.ToList(), PaginationVM = new() { ElementId = "#cities-pagination-partial-div", Url = Url.Action(nameof(CityController.GetCitiesPaginationPartial), MvcHelper.NameOfController <CityController>()), PageNumber = pageNumber, NumberOfEntitiesOnPage = numberOfEntitiesOnPage, NumberOfPages = Convert.ToInt32(Math.Ceiling((decimal)citiesPaginationReply?.NumberOfAllCities / numberOfEntitiesOnPage)) } }; return(PartialView(vm)); } }
public async Task <IActionResult> GetWeatherHistoryPaginationPartial(int pageNumber = 1, int numberOfEntitiesOnPage = 25) { var weatherHistoryForecastPagination = await _weatherHistoryClient.GetWeatherHistoryForecastPagination(pageNumber, numberOfEntitiesOnPage); WeatherHistoryPaginationPartialVM vm = new() { CityWeatherForecastDocuments = weatherHistoryForecastPagination?.WeatherForecastDocuments, PaginationVM = new() { ElementId = "#weather-history-pagination-partial-div", Url = Url.Action(nameof(WeatherHistoryController.GetWeatherHistoryPaginationPartial), MvcHelper.NameOfController <WeatherHistoryController>()), PageNumber = pageNumber, NumberOfEntitiesOnPage = numberOfEntitiesOnPage, NumberOfPages = Convert.ToInt32(Math.Ceiling((decimal)weatherHistoryForecastPagination?.NumberOfAllEntities / numberOfEntitiesOnPage)) } }; return(PartialView(vm)); } }