Пример #1
0
        private static List <Dto.Restaurant> GetAll()
        {
            // Get by id
            var restaurant1 = new RestaurantMenu.Dto.Restaurant
            {
                Id    = 1,
                Name  = "Coca Loca",
                Email = "*****@*****.**",
                RestaurantCategory = "Steak House"
            };

            var restaurant2 = new RestaurantMenu.Dto.Restaurant
            {
                Id    = 2,
                Name  = "Charlies Burger",
                Email = "*****@*****.**",
                RestaurantCategory = "comida chatarra"
            };

            var restaurant3 = new RestaurantMenu.Dto.Restaurant
            {
                Id    = 3,
                Name  = "Mcdonalds",
                Email = "*****@*****.**",
                RestaurantCategory = "comida gringa chatarra"
            };

            var listOfRestaurants = new List <Dto.Restaurant>();

            listOfRestaurants.Add(restaurant1);
            listOfRestaurants.Add(restaurant2);
            listOfRestaurants.Add(restaurant3);

            return(listOfRestaurants);
        }
Пример #2
0
        // /restaurants    -> Get All Restaurants
        // /restaurants/{Id} -> Get Restaurant By Id
        public object Get(RestaurantMenu.Dto.Restaurant request)
        {
            var response = new RestaurantResponse();

            try
            {
                if (request.Id.HasValue)
                {
                    var restaurant = GetById(request.Id.Value);
                    response.Restaurants.Add(restaurant);
                    response.Result = "1 Restaurant was found";
                }
                else
                {
                    response.Restaurants = GetAll();
                    response.Result      = "3 Restaurants were found";
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(response);
        }
Пример #3
0
        private static Dto.Restaurant GetById(int id)
        {
            // Get by id
            var restaurant = new RestaurantMenu.Dto.Restaurant
            {
                Id    = id,
                Name  = "Coca Loca",
                Email = "*****@*****.**",
                RestaurantCategory = "Steak House"
            };

            return(restaurant);
        }