public async Task <IActionResult> GetRestaurantsByCityAsync(
            [Required] long cityId,
            [FromQuery] GetRestaurantsByCityRq getRestaurantsByCityRq
            )
        {
            var result = await _restaurantService.GetRestaurantsByCityAsync(cityId, getRestaurantsByCityRq);

            return(result.data.IsOk()
                ? Ok(result.data.CreatePagedApiResponse(getRestaurantsByCityRq, result.count, Request))
                : (IActionResult)NotFound(result.CreateNotFoundApiResponse()));
        }
Esempio n. 2
0
        public async Task GetRestaurantsByCityAsync_ValidData_NotFound(long cityId)
        {
            var paginationRequest = new GetRestaurantsByCityRq();

            var result = await _cityController.GetRestaurantsByCityAsync(cityId, paginationRequest);

            _restaurantServiceMock.Verify(
                x => x.GetRestaurantsByCityAsync(It.Is <long>(v => v == cityId), It.IsAny <GetRestaurantsByCityRq>()),
                Times.Once);

            result.Should().NotBeNull();
            result.Should().BeOfType <NotFoundObjectResult>();
        }
        public Task <(IEnumerable <Restaurant> data, int count)> GetRestaurantsByCityAsync(long cityId, GetRestaurantsByCityRq getRestaurantsByCity)
        {
            getRestaurantsByCity.Validate();

            return(_restaurantRepository.GetRestaurantsByCityAsync(
                       cityId,
                       getRestaurantsByCity.PageNumber,
                       getRestaurantsByCity.PageSize));
        }