예제 #1
0
        public IActionResult ToSaveRecipe(int recipeId, string[] cuisine)
        {
            string      recipeCuisine = string.Empty;
            AspNetUsers user;

            if (User.Identity.Name != null)
            {
                KitchenSinkDBContext db = new KitchenSinkDBContext();
                user = db.AspNetUsers.Where(user => user.Email == User.Identity.Name.ToString()).FirstOrDefault();
            }
            //ViewBag.recipeId = recipeId;
            //ViewBag.recipeName = recipeName;
            //ViewBag.drinkid = drinkId;
            //ViewBag.drinkName = drinkName;

            newItems.RecipeId   = recipeId.ToString();
            recipeCuisine       = SetRecipeData(cuisine);
            newCuisine.Cuisine1 = recipeCuisine;
            //db.UserItems.Add(new UserItems
            //{
            //    DrinkId = drinkId,
            //    RecipeId = recipeId.ToString()
            //});
            //    db.SaveChanges();
            return(RedirectToAction("Drink", "Drink", newItems));
        }
        public IActionResult GetRec(string drinkCategory, string recipeCuisine)
        {
            KitchenSinkDBContext db    = new KitchenSinkDBContext();
            Recommendation       recom = new Recommendation();
            Drinks  drinks             = new Drinks();
            Cuisine cuisine            = new Cuisine();
            Genres  genres             = new Genres();
            int     drinkId            = 0;
            int     cuisineId          = 0;
            int     genreId            = 0;
            int     movieGenre         = 0;

            foreach (Drinks d in db.Drinks)
            {
                if (d.Category == drinkCategory)
                {
                    drinkId = d.Id;
                }
                //for when a drinkCategory is returned that does not match database
                else
                {
                    drinkId = random.Next(1, 6);
                }
            }
            foreach (Cuisine c in db.Cuisine)
            {
                if (c.Cuisine1 == recipeCuisine)
                {
                    cuisineId = c.Id;
                }
                //for when a cuisine is returned that does not match database
                else
                {
                    cuisineId = random.Next(1, 8);
                }
            }
            foreach (Recommendation rec in db.Recommendation)
            {
                if (rec.DrinkId == drinkId && rec.RecipeId == cuisineId)
                {
                    genreId = rec.GenreId;
                }
            }
            foreach (Genres gen in db.Genres)
            {
                if (gen.Id == genreId)
                {
                    movieGenre = gen.DbgenreId;
                }
            }
            return(RedirectToAction("GetRandomMovie", "Movie", movieGenre));
        }
        public IActionResult ToSaveRecipe(int recipeId, string[] cuisine)
        {
            string      recipeCuisine = string.Empty;
            AspNetUsers user;

            if (User.Identity.Name != null)
            {
                KitchenSinkDBContext db = new KitchenSinkDBContext();
                user = db.AspNetUsers.Where(user => user.Email == User.Identity.Name.ToString()).FirstOrDefault();
            }

            newItems.RecipeId   = recipeId.ToString();
            recipeCuisine       = SetRecipeData(cuisine);
            newCuisine.Cuisine1 = recipeCuisine;

            return(RedirectToAction("Drink", "Drink", newItems));
        }