public async Task <IActionResult> ExecuteAsync(string all, string code, ViewModels.CountryViewModels.PageOptions pageOptions, CancellationToken cancellationToken) { var country = await _countryRepository.GetCountryByCode(code, cancellationToken); if (country == null) { return(new NoContentResult()); } if (all == "1") { var zone = await _zoneRepository.PublicGetZoneAll(country.Id, cancellationToken); var zoneViewModels = _zoneMapper.MapList(zone); if (zone == null) { return(new NoContentResult()); } return(new OkObjectResult(zoneViewModels)); } var zones = await _zoneRepository.PublicGetZonePage(country.Id, pageOptions.Page.Value, pageOptions.Count.Value, cancellationToken); if (zones == null) { return(new NoContentResult()); } var totalCount = zones.Count; var totalPages = (int)Math.Ceiling(zones.Count / (double)pageOptions.Count.Value); var countryViewModels = _zoneMapper.MapList(zones); var page = new PageResult <PublicZone>() { Count = pageOptions.Count.Value, Items = countryViewModels, Page = pageOptions.Page.Value, TotalCount = totalCount, TotalPages = totalPages, }; return(new OkObjectResult(page)); }