public ActionResult AddDishAction(string dish_title, string dish_image, string[] dish_ingredient, int[] dish_ingredient_amount
                                          , string[] dish_step, string[] dish_tag, int dish_timecooking, string dish_category, string dish_description)
        {
            var  db   = new IFood();
            Dish dish = new Dish();

            try
            {
                dish.Id          = Guid.NewGuid();
                dish.Name        = dish_title;
                dish.ImageLink   = dish_image;
                dish.AuthorId    = db.Users.FirstOrDefault().Id;
                dish.IsActive    = true;
                dish.IsDelete    = false;
                dish.Rate        = 0;
                dish.TimeCooking = dish_timecooking + " minutes";


                dish.CreateOn    = DateTime.Now;
                dish.Description = dish_description;

                for (int i = 0; i < dish_ingredient.Length; i++)
                {
                    Dish_Ingredient dish_Ingredient = new Dish_Ingredient();
                    dish_Ingredient.IngredientId = Guid.Parse(dish_ingredient[i]);
                    dish_Ingredient.Amount       = dish_ingredient_amount[i];
                    var ingredient = dish_ingredient[i].ToString();
                    dish_Ingredient.UnitId      = int.Parse(db.Ingredients.Where(ing => ing.Id.ToString().Equals(ingredient)).First().UnitId.Trim());
                    dish_Ingredient.DishId      = dish.Id;
                    dish_Ingredient.Description = "";
                    dish.Dish_Ingredient.Add(dish_Ingredient);
                }

                for (int i = 0; i < dish_step.Length; i++)
                {
                    StepByStep step = new StepByStep();
                    step.DishId      = dish.Id;
                    step.Title       = "Step" + (i + 1);
                    step.Description = dish_step[i];
                    dish.StepBySteps.Add(step);
                }

                for (int i = 0; i < dish_tag.Length; i++)
                {
                    Course_Dish course = new Course_Dish();
                    course.CourseId = Guid.Parse(dish_tag[i]);
                    course.DishId   = dish.Id;
                    dish.Course_Dish.Add(course);
                }

                Category_Dish category = new Category_Dish();
                category.CategoryId  = Guid.Parse(dish_category);
                category.DishId      = dish.Id;
                category.Description = dish_description;
                dish.Category_Dish.Add(category);

                db.Dishes.Add(dish);
                db.SaveChanges();
            }
            catch (Exception e)
            {
            }
            return(RedirectToAction("AdminIndex"));
        }
        public ActionResult EditDishAction(string dish_id, string dish_title, string dish_image, string[] dish_ingredient, int[] dish_ingredient_amount
                                           , string[] dish_step, string[] dish_tag, int dish_timecooking, string dish_category, string dish_description)
        {
            var  db   = new IFood();
            Dish dish = db.Dishes.Where(d => d.Id.ToString().Equals(dish_id)).FirstOrDefault <Dish>();

            try
            {
                dish.Name        = dish_title;
                dish.ImageLink   = dish_image;
                dish.Description = dish_description;
                dish.TimeCooking = dish_timecooking + " minutes";

                for (int i = 0; i < dish_ingredient.Length; i++)
                {
                    var ingredient = dish_ingredient[i].ToString();
                    if (i >= dish.Dish_Ingredient.Count())
                    {
                        Dish_Ingredient dish_Ingredient = new Dish_Ingredient();
                        dish_Ingredient.IngredientId = Guid.Parse(dish_ingredient[i]);
                        dish_Ingredient.Amount       = dish_ingredient_amount[i];
                        dish_Ingredient.UnitId       = int.Parse(db.Ingredients.Where(ing => ing.Id.ToString().Equals(ingredient)).First().UnitId.Trim());
                        dish_Ingredient.DishId       = dish.Id;
                        dish_Ingredient.Description  = "";
                        dish.Dish_Ingredient.Add(dish_Ingredient);
                    }
                    else
                    {
                        dish.Dish_Ingredient.ElementAt(i).IngredientId = Guid.Parse(dish_ingredient[i]);
                        dish.Dish_Ingredient.ElementAt(i).Amount       = dish_ingredient_amount[i];
                        dish.Dish_Ingredient.ElementAt(i).UnitId       = int.Parse(db.Ingredients.Where(ing => ing.Id.ToString().Equals(ingredient)).First().UnitId.Trim());
                    }
                }

                for (int i = 0; i < dish_step.Length; i++)
                {
                    if (i >= dish.StepBySteps.Count())
                    {
                        StepByStep step = new StepByStep();
                        step.DishId      = dish.Id;
                        step.Title       = "Step" + (i + 1);
                        step.Description = dish_step[i];
                        dish.StepBySteps.Add(step);
                    }
                    else
                    {
                        dish.StepBySteps.ElementAt(i).Description = dish_step[i];
                    }
                }

                for (int i = 0; i < dish_tag.Length; i++)
                {
                    if (i >= dish.Course_Dish.Count())
                    {
                        Course_Dish course = new Course_Dish();
                        course.CourseId = Guid.Parse(dish_tag[i]);
                        course.DishId   = dish.Id;
                        dish.Course_Dish.Add(course);
                    }
                    else
                    {
                        dish.Course_Dish.ElementAt(i).CourseId = Guid.Parse(dish_tag[i]);
                    }
                }

                dish.Category_Dish.First().Description = dish_description;
                db.SaveChanges();
            }
            catch (Exception e)
            {
            }
            return(RedirectToAction("AdminIndex"));
        }