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); }
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); }
public IEnumerable <Food.Models.Food> GetFoods() { var foodRepo = new FoodRepo(); var foods = foodRepo.GetFoods(); return(foods); }
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); }
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); }
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); }
public FoodController(/*IFoodRepo foodRepo*/) { _foodRepo = new FoodRepo(); }
public FoodService(FoodRepo FoodRepo) { _FoodRepo = FoodRepo; }