Ejemplo n.º 1
0
        public IEnumerable <RestaurantModel> GetAll()
        {
            var restaurants = _restaurantRepository.GetAllWithType();

            foreach (var restaurant in restaurants)
            {
                var deliveryTime = restaurant.DeliveryTime == 0 ? 0 : Math.Min(100 * restaurant.DeliveryTime / 120, 100);

                yield return(new RestaurantModel
                {
                    RestaurantId = restaurant.RestaurantId,
                    Name = restaurant.RestaurantName,
                    TypeId = restaurant.RestaurantTypeId,
                    Type = restaurant.RestaurantType.Name,
                    Description = restaurant.RestaurantDescription,
                    DeliveryTime = restaurant.DeliveryTime,
                    DeliveryTimePercentage = deliveryTime,
                    PhotoBytes = restaurant.Photo
                });
            }
        }