//// GET: Home/Details/5
 //public ActionResult Details(int id)
 //{
 //    IngredientModel Ingredient = new IngredientModel();
 //    try
 //    {
 //        Ingredient = _service.GetIngredientById(id);
 //        Ingredient.TypeName = Enum.GetName(typeof(TypeNameEnum), Convert.ToInt32(Ingredient.TypeName));
 //        return PartialView("Partials/Details", Ingredient);
 //    }
 //    catch
 //    {
 //        return View();
 //    }
 //}
 // GET: Home/Edit/5
 public ActionResult Edit(int id)
 {
     IngredientModel Ingredient = new IngredientModel();
     Ingredient = _service.GetIngredientById(id);
     ViewData["typeNameList"] = TypeName.TypeNameList.AsEnumerable();
     return PartialView("Partials/Edit", Ingredient);
 }
        public ActionResult Edit(IngredientModel Ingredient)
        {
            try
            {
                Ingredient.TypeName = Enum.GetName(typeof(TypeNameEnum), Convert.ToInt32(Ingredient.TypeName));

                var result = _service.SaveIngredient(Ingredient);

                if (result != 0 && (TempData["Success"] == null || TempData["Error"] == null))
                    TempData["Success"] = "Successfully saved";
                else
                    TempData["Error"] = "Can't save data because  missed some values";

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
 // GET: Home/Delete/5
 public ActionResult Delete(int id)
 {
     IngredientModel Ingredient = new IngredientModel();
     Ingredient = _service.GetIngredientById(id);
     return PartialView("Partials/Delete", Ingredient);
 }