Пример #1
0
        public IActionResult Order(OrderMealViewModel model)
        {
            if (User.Identity.IsAuthenticated)
            {
                //// Fetching Dishes into local JArray
                //JArray mealArray = await MealMethods.GetMeals();
                //// Converting JArray items to Collection object of given type
                //List<Meal> allMeals = mealArray.ToObject<List<Meal>>();

                List <Meal> allMeals = _mealService.GetMeals();

                if (ModelState.IsValid)
                {
                    foreach (var item in model.DayMeals)
                    {
                        foreach (var meal in allMeals)
                        {
                            if (meal.Id == item.Value && item.Value != 0)
                            {
                                _cart.AddItem(meal, (DayOfWeek)item.Key);
                            }
                        }
                    }
                    return(RedirectToAction("Cart", "Cart"));
                }
                return(RedirectToAction("ChooseWeek", "Order"));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
        public ViewResult Dashboard()
        {
            List <Menu> menus  = _menuService.GetMenus();
            List <Meal> meals  = _mealService.GetMeals();
            List <Dish> dishes = _dishService.GetDishes();

            ViewBag.Menus  = menus;
            ViewBag.Meals  = meals;
            ViewBag.Dishes = dishes;
            return(View("Dashboard"));
        }
        public IActionResult GetAll()
        {
            var data = mealService.GetMeals().Select(x => new
            {
                Id           = x.Id,
                Name         = x.Name,
                Price        = x.Price,
                MealType     = x.MealType,
                MealCategory = x.MealCategory
            });

            return(Ok(data));
        }
        public ActionResult <IEnumerable <MealViewModel> > GetMeals()
        {
            var meals      = _service.GetMeals();
            var mealModels = new List <MealViewModel>();

            meals.ForEach(m =>
            {
                var dishes = new List <Dish>();
                foreach (var md in m.Dishes)
                {
                    dishes.Add(_dishService.GetDishById(md.DishId));
                }
                var model = new MealViewModel {
                    DateValid = m.DateValid, Id = m.Id, Dishes = dishes
                };
                mealModels.Add(model);
            });

            return(mealModels);
        }
        // GET: Meals
        public ViewResult Index()
        {
            List <MealDishes> mealDishes = new List <MealDishes>();
            List <Dish>       allDishes  = new List <Dish>();

            var dishes = _mealService.GetAllMealDishes();
            var x      = _dishService.GetDishes();

            foreach (var item in dishes)
            {
                mealDishes.Add(item);
            }
            foreach (var item in x)
            {
                allDishes.Add(item);
            }

            ViewBag.MealDishes = mealDishes;
            ViewBag.Dishes     = allDishes;
            return(View(_mealService.GetMeals()));
        }
Пример #6
0
 // GET: api/Meals
 public IEnumerable <MealDto> GetMeals()
 {
     return(msvc.GetMeals().Select(b => MealDto.FromMeal(b)));
 }
Пример #7
0
 public List <MealModel> Filter([FromBody] FindMealRequest request)
 {
     return(_mealService.GetMeals(_loggedInUser, request.UserId, request.FromDate, request.ToDate, request.FromTime, request.ToTime));
 }