////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Handles GET requests for the Drink View </summary>
        /// <remarks>   Andre Beging, 28.04.2018. </remarks>
        /// <param name="id">   The identifier. </param>
        /// <param name="successMessage"></param>
        /// <returns>   An IActionResult. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public IActionResult Drink(Guid id, string successMessage = null)
        {
            if (id == Guid.Empty)
            {
                return(RedirectToAction("Drinks"));
            }

            var model = new ManageDrinkModel();

            using (var context = ContextHelper.OpenContext())
            {
                var contextDrink = context.Drink
                                   .Include(d => d.DrinkEntries)
                                   .FirstOrDefault(e => e.DrinkId == id);

                if (contextDrink == null)
                {
                    return(RedirectToAction("Drinks"));
                }

                model.DrinkId    = contextDrink.DrinkId;
                model.Name       = contextDrink.Name;
                model.Visible    = contextDrink.Visible;
                model.Amount     = contextDrink.Amount;
                model.Percentage = contextDrink.Percentage;
                model.UsageCount = contextDrink.DrinkEntries.Count;
            }

            if (successMessage != null)
            {
                ViewData["SuccessMessage"] = successMessage;
            }

            return(View(model));
        }
        public IActionResult Drink(ManageDrinkModel model)
        {
            string successMessage = null;

            if (ModelState.IsValid)
            {
                using (var context = ContextHelper.OpenContext())
                {
                    var contextDrink = context.Drink.FirstOrDefault(d => d.DrinkId == model.DrinkId);
                    if (contextDrink != null)
                    {
                        contextDrink.Name = model.Name;
                        context.SaveChanges();

                        successMessage = "Getränk gespeichert!";
                    }
                }
            }

            return(RedirectToAction("Drink", new { id = model.DrinkId, successMessage }));
        }