public ActionResult CreatePost(IFormCollection arg, MealWithMealTypesViewModel PostMeal)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Create"));
            }

            var ingredientNums        = PostMeal.PostIngredients;
            var queryReadyIngredients = ingredientNums.Select(x => int.Parse(x));
            var query = from num in queryReadyIngredients
                        join Ingredient in PostMeal.AllIngredientsFromViewModel on num equals Ingredient.Id
                        select new { Id = Ingredient.Id, Name = Ingredient.Name };
            var lista = query.ToList();
            List <Ingredient> queryIngredients = new List <Ingredient>();
            var counter = 0;

            foreach (var item in lista)
            {
                Ingredient i = new Ingredient(lista.Skip(counter).First().Id, lista.Skip(counter).First().Name);
                queryIngredients.Add(i);
                counter++;
            }

            PostMeal.meal.Ingredients = queryIngredients;
            PostMeal.meal.MealType    = arg["Type"].ToString();
            MealHelper.AddMeal(PostMeal.meal);


            return(RedirectToAction("Index"));
        }
        public ActionResult Details(string mealType)
        {
            var viewModel = new MealWithMealTypesViewModel
            {
                meals = MealHelper.GetAllMeals().Where(m => m.MealType.Equals(mealType)).ToList()
            };

            return(View("Meals", viewModel));
        }
        public ActionResult Index()
        {
            var viewModel = new MealWithMealTypesViewModel
            {
                meals = MealHelper.GetAllMeals(),
            };

            return(View("Meals", viewModel));
        }
        public ActionResult Create()
        {
            var viewModel = new MealWithMealTypesViewModel
            {
                MealTypes   = MealHelper.GetAllMealTypes(),
                Ingredients = MealHelper.GetAllIngredients().Select(i => new SelectListItem {
                    Value = i.Id.ToString(), Text = i.Name
                }).ToList(),
                PostIngredients = new List <string>()
            };

            return(View("CreateMealForm", viewModel));
        }