Ejemplo n.º 1
0
        public MenuModel GetMenuByDate(DateTime date)
        {
            var menuRepo       = new MenuRepo();
            var menuDetailRepo = new MenuDetailRepo();
            var foodRepo       = new FoodRepo();
            var menu           = menuRepo.GetMenuByDate(date);
            var menuModel      = new MenuModel()
            {
                Id          = menu.Id,
                Name        = menu.Name,
                Date        = menu.Date,
                MenuDetails = menuDetailRepo.GetMenuDetailByMenu(menu.Id)
                              .Select(md => new MenuDetailModel()
                {
                    Id   = md.Id,
                    Food = foodRepo.GetFoodsById(md.FoodId).Select(f => new FoodModel()
                    {
                        Id   = f.Id,
                        Name = f.Name,
                        Type = f.Type
                    }).First()
                })
            };

            return(menuModel);
        }
Ejemplo n.º 2
0
        private FoodInfo CreateNewFood(string category, string food)
        {
            var pictureUrls = BingFacade.FindImages(String.Format("{0} - {1}", category, food));


            var pictureId = 0;
            var pictures  = new List <FoodPicture>();

            foreach (var url in pictureUrls)
            {
                pictures.Add(new FoodPicture
                {
                    Id             = pictureId,
                    Url            = url,
                    Relevance      = 0,
                    IsUserUploaded = false
                });
                pictureId++;
            }

            var newFood = new FoodInfo
            {
                Category = category,
                Food     = food,
                Pictures = pictures
            };

            FoodRepo.Store(newFood);
            return(newFood);
        }
Ejemplo n.º 3
0
        public IEnumerable <Food.Models.Food> GetFoods()
        {
            var foodRepo = new FoodRepo();
            var foods    = foodRepo.GetFoods();

            return(foods);
        }
Ejemplo n.º 4
0
        public IEnumerable <FoodModel> GetSecondaryFoods()
        {
            var foodRepo = new FoodRepo();
            var foods    = foodRepo.GetFoods().Where(f => f.Type == 2)
                           .Select(f => new FoodModel()
            {
                Id = f.Id, Name = f.Name, Type = f.Type
            })
                           .OrderBy(f => f.Name);

            return(foods);
        }
Ejemplo n.º 5
0
        public FoodInfo FindFoodInfo(string category, string food)
        {
            category = category.ToLower();
            food     = food.ToLower();

            var foodInfo = FoodRepo.Get(category, food);

            if (foodInfo == null)
            {
                return(CreateNewFood(category, food));
            }

            foodInfo.Pictures = foodInfo.Pictures.OrderByDescending(p => p.Relevance).ToList();

            return(foodInfo);
        }
Ejemplo n.º 6
0
        public OrderModel GetOrderByDate(DateTime date, string userId)
        {
            var orderRepo = new OrderRepo();
            var order     = orderRepo.GetOrderByDateAndUser(date, userId);
            //var statusRepo = new StatuRepo();
            //var status = statusRepo.GetOrderStatus(1);//1 = Pedido; 2 = Entregado; 3 = Cancelado
            //var orderDetailRepo = new OrderDetailRepo();
            var foodRepo   = new FoodRepo();
            var menu       = GetMenuByDate(date);
            var orderModel = new OrderModel()
            {
                Date         = date,
                UserId       = userId,
                Menu         = menu,
                OrderDetails = new List <OrderDetailModel>()
                               //OrderDetails = order == null ? new List<OrderDetailModel>() : orderDetailRepo.GetOrderDetailsByOrder(order.Id)
                               //.Select(od => new OrderDetailModel() {
                               //    Food = foodRepo.GetFoodById(od.FoodId)
                               //})
            };

            return(orderModel);
        }
Ejemplo n.º 7
0
 public FoodController(/*IFoodRepo foodRepo*/)
 {
     _foodRepo = new FoodRepo();
 }
Ejemplo n.º 8
0
 public FoodService(FoodRepo FoodRepo)
 {
     _FoodRepo = FoodRepo;
 }