예제 #1
0
        public ActionResult <List <SearchRestaurant> > SearchRestaurant(string restaurantName)
        {
            try
            {
                var result = _repository.SearchRestaurant(restaurantName);
                if (!result.Any())
                {
                    return(NotFound("Failed to find restaurant with the given name"));
                }

                IMapper mapper = EDeliveryProfile.SearchRestaurant();
                return(mapper.Map <List <SearchRestaurant> >(result));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to find the restaurants with the given name: {ex}");
                return(BadRequest());
            }
        }