public async Task <IActionResult> AddComment(CocktailViewModel cocktail)
        {
            int userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
            var author = HttpContext.User.Identity.Name;

            var cocktailComment = new CocktailCommentViewModel
            {
                Text       = cocktail.CurrentComment,
                CocktailId = cocktail.Id,
                UserId     = userId,
                Author     = author
            };

            var cocktailCommentDto = this.cocktailCommentVmMapper.MapDTO(cocktailComment);

            var comment = await this.cocktailCommentService.CreateCocktailCommentAsync(cocktailCommentDto);

            var currentCocktail = await this.cocktailService.GetCokctailAsync(comment.CocktailId);

            var cocktailVm  = this.cocktailVmMapper.MapViewModel(currentCocktail);
            var dtoComments = await this.cocktailCommentService.GetCocktailCommentsAsync(cocktailVm.Id);

            cocktailVm.Comments      = this.cocktailCommentVmMapper.MapViewModel(dtoComments);
            cocktailVm.AverageRating = this.cocktailRatingService.GetAverageCocktailRating(cocktailComment.Id);

            return(RedirectToAction("Details", "Cocktails", new { area = "", id = cocktailVm.Id }));
        }
Example #2
0
        public async Task <IActionResult> UpdateAvailableIngredients(CocktailViewModel tempCocktailVm)
        {
            var cocktail = await this.context.Cocktails
                           .Where(b => b.IsDeleted == false)
                           .Include(b => b.CocktailIngredients)
                           .ThenInclude(bc => bc.Ingredient)
                           .FirstOrDefaultAsync(c => c.Id == tempCocktailVm.Id);

            this.context.CocktailIngredients.RemoveRange(cocktail.CocktailIngredients);
            await this.context.SaveChangesAsync();

            var ingredientForCocktails = await this._ingredientService.GetCocktailIngredientsAsync(cocktail.Id);

            var ingredientForCocktailIds = ingredientForCocktails.Select(c => c.Id);


            foreach (var item in tempCocktailVm.SelectedIngredients)
            {
                if (item.isChecked == true && !ingredientForCocktailIds.Contains(item.Id))
                {
                    await this._cocktailIngredientService.CreateCocktailIngredientAsync(cocktail.Id, item.Id);
                }
            }

            return(RedirectToAction("Details", "Cocktails", new { area = "", id = cocktail.Id }));
        }
Example #3
0
        public async Task <IActionResult> AddRating(CocktailViewModel cocktail)
        {
            int userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));

            var cocktailRating = new CocktailRatingViewModel
            {
                Value      = (cocktail.SelectedRating),
                CocktailId = cocktail.Id,
                UserId     = userId,
            };

            var cocktailRatingDto = this.cocktailRatingVmMapper.MapDTO(cocktailRating);

            var rating = await this.cocktailRatingService.CreateRatingAsync(cocktailRatingDto);

            var currentCocktail = await this.cocktailService.GetCokctailAsync(rating.CocktailId);

            var cocktailVM = this.cocktailVmMapper.MapViewModel(currentCocktail);

            var DtoComments = await this.cocktailCommentService.GetCocktailCommentsAsync(cocktailVM.Id);

            cocktailVM.Comments      = this.cocktailCommentVmMapper.MapViewModel(DtoComments);
            cocktailVM.AverageRating = this.cocktailRatingService.GetAverageCocktailRating(cocktail.Id);

            return(RedirectToAction("Details", "Cocktails", new { area = "", id = cocktailVM.Id }));
        }
Example #4
0
        public async Task <IActionResult> AddCocktail(CocktailViewModel vm)
        {
            if (await _cocktailServices.CocktailWithThatNameExists(vm.Name))
            {
                ModelState.AddModelError(string.Empty, "Cocktail with that name already exists.");
                return(View());
            }
            if (vm.NewPicture != null)
            {
                using (var stream = new MemoryStream())
                {
                    await vm.NewPicture.CopyToAsync(stream);

                    vm.Picture = stream.ToArray();
                }
            }
            var cocktail = await _cocktailServices.AddAsync(vm.Name, vm.Picture);

            var ingredients = await _ingredientServices.GetMultipleIngredientsByNameAsync(vm.Ingredients);

            for (int i = 0; i < vm.Quantities.Count; i++)
            {
                await _cocktailIngredientsServices.AddAsync(cocktail, ingredients[i], vm.Quantities[i]);
            }

            foreach (var bar in vm.Bars)
            {
                var barEntity = await _barServices.GetAsync(bar);

                await _barCocktailServices.CreateAsync(barEntity, cocktail);
            }
            return(RedirectToAction("UpdateCocktail", new { id = cocktail.Id }));
        }
        public CocktailViewModel MapToVMFromDTO(CocktailDTO cocktailDTO)
        {
            if (cocktailDTO == null)
            {
                return(null);
            }
            var cocktailVM = new CocktailViewModel
            {
                Id            = cocktailDTO.Id,
                Name          = cocktailDTO.Name,
                AverageRating = cocktailDTO.AverageRating,
                Bars          = cocktailDTO.Bars.Select(b => new BarViewModel
                {
                    Id   = b.Id,
                    Name = b.Name,
                    //Address = b.Address,
                    CityName = b.CityName,
                    //Phone = b.Phone,
                    AverageRating = b.AverageRating
                }).ToList(),
                Ingredients = cocktailDTO.Ingredients.Select(i => new IngredientViewModel
                {
                    Id   = i.Id,
                    Name = i.Name
                }).ToList(),
                ImageData   = cocktailDTO.ImageData,
                ImageSource = cocktailDTO.ImageSource
            };

            return(cocktailVM);
        }
Example #6
0
        // GET: Cocktails
        public async Task <IActionResult> Index()
        {
            var userId   = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var homeCook = _context.HomeCook.Where(c => c.IdentityUserId ==
                                                   userId).SingleOrDefault();
            DrinkIngredient drinkIngredient = await _cocktailIngredientRequest.GetDrinkIngredient();

            List <SelectListItem> ingredients = new List <SelectListItem>();
            var _ingredients = drinkIngredient.drinks.Select(a => new SelectListItem()
            {
                Text  = a.strIngredient1,
                Value = a.strIngredient1
            });

            ingredients = _ingredients.OrderBy(a => a.Text).ToList();
            string    selectedIngredient = ingredients.Select(a => a.Value).FirstOrDefault().ToString();
            Cocktails cocktails          = await _cocktailByIngredientRequest.GetCocktailsByIngredients(selectedIngredient);

            CocktailViewModel cocktailView = new CocktailViewModel()
            {
                Cocktail    = cocktails,
                Ingredients = ingredients,
                HomeCook    = homeCook
            };

            return(View(cocktailView));
        }
Example #7
0
        public ActionResult Save(Cocktail cocktail)
        {
            if (!ModelState.IsValid)
            {
                var cocktailViewModel = new CocktailViewModel(cocktail)
                {
                    Themes = _context.Themes.ToList()
                };
                return(View("New", cocktailViewModel));
            }

            if (cocktail.Id == 0)
            {
                _context.Cocktails.Add(cocktail);
            }
            else
            {
                var cocktailInDb = _context.Cocktails.SingleOrDefault(c => c.Id == cocktail.Id);
                cocktailInDb.Name        = cocktail.Name;
                cocktailInDb.Price       = cocktail.Price;
                cocktailInDb.Description = cocktail.Description;
                cocktailInDb.ThemeId     = cocktail.ThemeId;
            }
            _context.SaveChanges();
            return(RedirectToAction("Index", "Cocktail"));
        }
Example #8
0
        private CocktailViewModel GenerateViewModel(RECIPE recipe)
        {
            List <ALLERGEN> allergens = new List <ALLERGEN>();
            List <INGREDIENT_NUTRITIONAL_INFO> nutInfo     = new List <INGREDIENT_NUTRITIONAL_INFO>();
            List <RECIPE_INGREDIENT>           ingredients = recipe.RECIPE_INGREDIENT.ToList();

            foreach (RECIPE_INGREDIENT item in ingredients)
            {
                var ingAllergen = item.INGREDIENT.INGREDIENT_ALLERGEN;
                foreach (var ing in ingAllergen.Where(i => i.Present == true))
                {
                    allergens.Add(ing.ALLERGEN);
                }
                nutInfo.AddRange(item.INGREDIENT.INGREDIENT_NUTRITIONAL_INFO);
            }

            NutritionLabel label = new NutritionLabel(nutInfo);

            //TODO: Gather together the nutinfos and add them up rather than having duplicates
            CocktailViewModel model = new CocktailViewModel()
            {
                Recipe         = recipe,
                Allergens      = allergens.Distinct().ToList(),
                NutritionLabel = label
            };

            return(model);
        }
Example #9
0
        public async Task <IActionResult> AvailableIngredients(int Id)
        {
            var cocktail = await this.cocktailService.GetCokctailAsync(Id);

            var allIngredients = await this._ingredientService.GetAllIngredientsAsync();

            var allIngredientsVm = allIngredients
                                   .Select(x => this._ingredientVmMapper.MapViewModel(x))
                                   .Select(x => new CheckBoxItem()
            {
                Id        = x.Id,
                Title     = x.Name,
                isChecked = context.CocktailIngredients.Any(bc => bc.CocktailId == Id && bc.IngredientId == x.Id) ? true : false,
            }).ToList();

            var availableIngredients = await this._ingredientService.GetCocktailIngredientsAsync(Id);

            var availableIngredientsVm = this._ingredientVmMapper.MapViewModel(availableIngredients);

            var cocktailVm = new CocktailViewModel
            {
                Id   = cocktail.Id,
                Name = cocktail.Name,
                SelectedIngredients = allIngredientsVm,
                IngredientsChange   = availableIngredientsVm,
            };

            return(View(cocktailVm));
        }
        public static CocktailViewModel MapToViewModel(this Cocktail cocktail)
        {
            var vm = new CocktailViewModel();

            vm.Id              = cocktail.Id;
            vm.Name            = cocktail.Name;
            vm.IsHidden        = cocktail.IsHidden;
            vm.Picture         = cocktail.Picture;
            vm.CocktailReviews = cocktail.CocktailReviews;
            try
            {
                vm.Rating = Math.Round(cocktail.CocktailReviews.Select(b => b.Rating).Average(), 2);
            }
            catch (Exception)
            {
                vm.Rating = 0;
            }
            try
            {
                vm.Bars = cocktail.Bars.Select(b => b.Bar.Name).ToList();
            }
            catch (Exception)
            {
                vm.Bars = null;
            }
            try
            {
                vm.Ingredients = cocktail.Ingredients.Select(b => b.Ingredient.Name).ToList();
            }
            catch (Exception)
            {
                vm.Ingredients = null;
            }
            return(vm);
        }
        public async Task <IActionResult> CocktailDetails(string cocktailId)
        {
            var Cocktail = await cocktailService.FindCocktailByIdAsync(int.Parse(cocktailId));

            var vm = new CocktailViewModel(Cocktail);

            return(View("CocktailDetails", vm));
        }
Example #12
0
        public ActionResult New()
        {
            var cocktailViewModel = new CocktailViewModel()
            {
                Themes = _context.Themes.ToList()
            };

            return(View(cocktailViewModel));
        }
Example #13
0
        public ActionResult Edit(int id)
        {
            var cocktail          = _context.Cocktails.Single(c => c.Id == id);
            var cocktailViewModel = new CocktailViewModel(cocktail)
            {
                Themes = _context.Themes.ToList()
            };

            return(View("New", cocktailViewModel));
        }
        public async Task <IActionResult> AddCocktailComment(CocktailViewModel vm)
        {
            var userId = this.User.GetId();
            await aService.AddCocktailCommentAsync(vm.Id, vm.CreateComment, userId);

            var cocktail = await cocktailService.FindCocktailByIdAsync(vm.Id); // do we need this

            var cocktailForView = new CocktailViewModel(cocktail);

            return(View("CocktailDetails", cocktailForView));
        }
        // GET: Cocktails/Cocktails/Create
        public async Task <IActionResult> Create(CocktailViewModel cocktail)
        {
            var ingredients = await ingredientService.GetAllIngredients();

            var ingredientsVM = ingredients
                                .Select(i => i.IngredientDTOMapToVM());

            cocktail.Ingredients = ingredientsVM.ToList();
            // var allIngredients = await ingredientsVM.ToListAsync();

            return(View(cocktail));
        }
        public static CocktailViewModel ToCatalogVM(this CocktailDTO cocktail)
        {
            var cocktailViewModel = new CocktailViewModel()
            {
                CocktailId  = cocktail.Id,
                Information = cocktail.Information,
                Name        = cocktail.Name,
                Picture     = cocktail.Picture,
                Rating      = cocktail.Rating
            };

            return(cocktailViewModel);
        }
Example #17
0
        public ActionResult Create()
        {
            CocktailViewModel model = new CocktailViewModel();

            model.SelectedIngredients = new List <int?>();
            model.RecipeSteps         = new List <string>()
            {
                null, null, null, null, null,
            };
            model.Ingredients = new SelectList(db.INGREDIENT, "IngredientId", "Name");
            model.Categories  = new SelectList(db.RECIPE_CATEGORY, "Recipe_CategoryId", "Name");
            return(View(model));
        }
        public static CocktailDTO ToDTO(this CocktailViewModel cocktailView)
        {
            var cocktailViewModel = new CocktailDTO()
            {
                //Id = cocktailView.CocktailId,
                //Information = cocktailView.Information,
                Name               = cocktailView.Name,
                Picture            = cocktailView.Picture,
                Rating             = cocktailView.Rating,
                CocktailReviewDTOs = cocktailView.ReviewViewModels?.ToCocktailReviewDTO()
            };

            return(cocktailViewModel);
        }
        public static CocktailViewModel ToEditVM(this CocktailDTO cocktail)
        {
            var cocktailViewModel = new CocktailViewModel()
            {
                CocktailId          = cocktail.Id,
                Information         = cocktail.Information,
                Name                = cocktail.Name,
                Picture             = cocktail.Picture,
                Rating              = cocktail.Rating,
                CocktailIngredients = cocktail.CocktailIngredientDTOs.ToVM()
            };

            return(cocktailViewModel);
        }
        public static CocktailDTO ToEditDTO(this CocktailViewModel cocktailView)
        {
            var cocktailDTO = new CocktailDTO()
            {
                Id                     = cocktailView.CocktailId,
                Information            = cocktailView.Information,
                Name                   = cocktailView.Name,
                Picture                = cocktailView.Picture,
                Rating                 = cocktailView.Rating,
                CocktailIngredientDTOs = cocktailView.CocktailIngredients != null?cocktailView.CocktailIngredients.ToDTO() : new List <CocktailIngredientDTO>()
            };

            return(cocktailDTO);
        }
        public static CocktailViewModel ToVM(this CocktailDTO cocktail)
        {
            var cocktailViewModel = new CocktailViewModel()
            {
                CocktailId       = cocktail.Id,
                Information      = cocktail.Information,
                Name             = cocktail.Name,
                Picture          = cocktail.Picture,
                Rating           = cocktail.Rating,
                ReviewViewModels = cocktail.CocktailReviewDTOs.ToCocktailReviewVM()
            };

            return(cocktailViewModel);
        }
Example #22
0
        public ActionResult Create([Bind(Include = "Recipe,SelectedIngredients,RecipeSteps,Allergens,NutritionalInfo,ViewBag")] CocktailViewModel model)
        {
            if (ModelState.IsValid)
            {
                //recipe
                model.Recipe.SubmittedBy   = User.Identity.GetUserId();
                model.Recipe.ModifiedBy    = model.Recipe.SubmittedBy;
                model.Recipe.SubmittedDate = DateTime.Now;
                model.Recipe.ModifiedDate  = model.Recipe.SubmittedDate;
                db.RECIPE.Add(model.Recipe);
                db.SaveChanges();

                var recipeId = model.Recipe.RecipeId;

                //recipe step
                int stepCount = 1;
                foreach (string step in model.RecipeSteps.Where(s => s != null).Where(s => s != ""))
                {
                    RECIPE_STEP recStep = new RECIPE_STEP()
                    {
                        Description = step.ToString(),
                        RecipeId    = recipeId,
                        StepNr      = stepCount
                    };
                    stepCount++;
                    db.RECIPE_STEP.Add(recStep);
                }


                //recipe ingredients
                foreach (int?ing in model.SelectedIngredients.Where(i => i != null))
                {
                    RECIPE_INGREDIENT recIng = new RECIPE_INGREDIENT()
                    {
                        Amount       = 1,
                        IngredientId = (int)ing,
                        RecipeId     = recipeId
                    };
                    db.RECIPE_INGREDIENT.Add(recIng);
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Category    = new SelectList(db.RECIPE_CATEGORY, "Recipe_CategoryId", "Name", model.Recipe.Category);
            ViewBag.ModifiedBy  = new SelectList(db.AspNetUsers, "Id", "FirstName", model.Recipe.ModifiedBy);
            ViewBag.SubmittedBy = new SelectList(db.AspNetUsers, "Id", "FirstName", model.Recipe.SubmittedBy);
            return(View(model));
        }
        public static CocktailViewModel MapToCocktailViewModel(this CocktailDto cocktailDto)
        {
            var cocktailVm = new CocktailViewModel();

            cocktailVm.Id                 = cocktailDto.Id;
            cocktailVm.Name               = cocktailDto.Name;
            cocktailVm.Rating             = (double)Math.Round((decimal)(cocktailDto.Rating ?? 0), 2);
            cocktailVm.Image              = cocktailDto.Image;
            cocktailVm.DateDeleted        = cocktailDto.DateDeleted;
            cocktailVm.CocktailComponents = cocktailDto.Ingredients.Select(i => i.MapToCocktailComponentVM()).ToList();
            cocktailVm.BarCocktails       = cocktailDto.BarCocktails;
            cocktailVm.LikeCount          = cocktailDto.LikeCount;
            cocktailVm.LikeByUsers        = cocktailDto.LikedByUsers;
            //cocktailVm.Ingredients = cocktailDto.Ingredients.Select(i => i.MapIngredientToViewModel());
            return(cocktailVm);
        }
        public static CocktailDto MapToCocktailDTO(this CocktailViewModel cocktailVM)
        {
            var cocktailDto = new CocktailDto();

            cocktailDto.Id            = cocktailVM.Id;
            cocktailDto.Name          = cocktailVM.Name;
            cocktailDto.Image         = cocktailVM.Image;
            cocktailDto.CocktailImage = cocktailVM.CocktailImage;
            cocktailDto.Ingredients   = cocktailVM.Ingredients
                                        .Where(i => i.Ingredient != null)
                                        .Select(
                i => i.MapCockTailComponentVMToDTo()
                ).ToList();
            cocktailDto.Recipe = cocktailVM.Recipe;
            return(cocktailDto);
        }
        public async Task <IActionResult> Edit(int id, CocktailViewModel cocktail)
        {
            if (id != cocktail.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var barDTO = this._cocktailVmMapper.MapDTO(cocktail);
                await this._cocktailService.UpdateCocktailAsync(barDTO);

                return(RedirectToAction("List", "Cocktails", new { area = "" }));
            }
            return(RedirectToAction("List", "Cocktails", new { area = "" }));
        }
Example #26
0
        public async Task <IActionResult> SaveDrink(CocktailViewModel cocktailView)
        {
            var userId   = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var homeCook = _context.HomeCook.Where(c => c.IdentityUserId ==
                                                   userId).SingleOrDefault();

            cocktailView.HomeCook = homeCook;
            _context.SavedDrinks.Add(new SavedDrinks()
            {
                Name         = cocktailView.CocktailDescription.drinks[0].strDrink,
                Ingredient1  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure1} {cocktailView.CocktailDescription.drinks[0].strIngredient1}",
                Ingredient2  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure2} {cocktailView.CocktailDescription.drinks[0].strIngredient2}",
                Ingredient3  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure3} {cocktailView.CocktailDescription.drinks[0].strIngredient3}",
                Ingredient4  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure4} {cocktailView.CocktailDescription.drinks[0].strIngredient4}",
                Ingredient5  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure5} {cocktailView.CocktailDescription.drinks[0].strIngredient5}",
                Ingredient6  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure6} {cocktailView.CocktailDescription.drinks[0].strIngredient6}",
                Ingredient7  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure7} {cocktailView.CocktailDescription.drinks[0].strIngredient7}",
                Ingredient8  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure8} {cocktailView.CocktailDescription.drinks[0].strIngredient8}",
                Ingredient9  = $"{cocktailView.CocktailDescription.drinks[0].strMeasure9} {cocktailView.CocktailDescription.drinks[0].strIngredient9}",
                Ingredient10 = $"{cocktailView.CocktailDescription.drinks[0].strMeasure10} {cocktailView.CocktailDescription.drinks[0].strIngredient10}",
                Ingredient11 = $"{cocktailView.CocktailDescription.drinks[0].strMeasure11} {cocktailView.CocktailDescription.drinks[0].strIngredient11}",
                Ingredient12 = $"{cocktailView.CocktailDescription.drinks[0].strMeasure12} {cocktailView.CocktailDescription.drinks[0].strIngredient12}",
                Ingredient13 = $"{cocktailView.CocktailDescription.drinks[0].strMeasure13} {cocktailView.CocktailDescription.drinks[0].strIngredient13}",
                Ingredient14 = $"{cocktailView.CocktailDescription.drinks[0].strMeasure14} {cocktailView.CocktailDescription.drinks[0].strIngredient14}",
                Ingredient15 = $"{cocktailView.CocktailDescription.drinks[0].strMeasure15} {cocktailView.CocktailDescription.drinks[0].strIngredient15}",
                Recipe       = cocktailView.CocktailDescription.drinks[0].strInstructions,
                HomeCook     = homeCook
            });
            DrinkIngredient drinkIngredient = await _cocktailIngredientRequest.GetDrinkIngredient();

            List <SelectListItem> ingredients = new List <SelectListItem>();
            var _ingredients = drinkIngredient.drinks.Select(a => new SelectListItem()
            {
                Text  = a.strIngredient1,
                Value = a.strIngredient1
            });

            ingredients = _ingredients.OrderBy(a => a.Text).ToList();
            string    selectedIngredient = ingredients.Select(a => a.Value).FirstOrDefault().ToString();
            Cocktails cocktails          = await _cocktailByIngredientRequest.GetCocktailsByIngredients(selectedIngredient);

            cocktailView.Cocktail    = cocktails;
            cocktailView.Ingredients = ingredients;
            _context.SaveChanges();
            return(View("Index", cocktailView));
        }
Example #27
0
        // GET: Recipes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE recipe = db.RECIPE.Find(id);

            if (recipe == null)
            {
                return(HttpNotFound());
            }

            CocktailViewModel model = GenerateViewModel(recipe);

            return(View(model));
        }
Example #28
0
        // GET: Recipes/Details/5
        public ActionResult SearchRecipe(string search)
        {
            if (string.IsNullOrEmpty(search))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE recipe = db.RECIPE.Where(r => r.Name.Contains(search)).FirstOrDefault();

            if (recipe == null)
            {
                return(HttpNotFound());
            }

            CocktailViewModel model = GenerateViewModel(recipe);

            return(View("Details", model));
        }
        public async Task <IActionResult> AddIngredients(CocktailViewModel model, Guid cocktailId)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await cocktailServices.AddIngredientsToCocktail(cocktailId, model.IngredientIds);

                    this.toast.AddSuccessToastMessage($"Successfully added to {model.Name}");
                    return(RedirectToAction("ListCocktails", "Cocktail", new { Area = "" }));
                }
                catch (Exception e)
                {
                    this.toast.AddErrorToastMessage(Exceptions.SomethingWentWrong);
                    return(RedirectToAction("ListCocktails", new { Area = "" }));
                }
            }
            return(NoContent());
        }
        public async Task <IActionResult> ListCocktails(int?currentPage, string searchCriteria)
        {
            ViewData["SearchParm"] = searchCriteria;

            var cocktails = await this.cocktailServices.GetIndexPageCocktails(currentPage ?? 1, searchCriteria);

            var ingredients = await ingredientServices.GetAllIngredients(null);

            var cocktailViewModel = cocktails.GetViewModels();
            var paged             = new CocktailViewModel()
            {
                IngredientsToChoose = ingredients.Select(c => new SelectListItem(c.Name, c.Name)).ToList(),
                currentPage         = currentPage ?? 1,
                items      = cocktailViewModel,
                TotalPages = this.cocktailServices.GetCount(10)
            };

            return(View(paged));
        }