public PartialViewResult GetItem(int id) { var ingredient = _ingredientRepository.GetIngredientByRecipe(id); var viewitems = new List <IngredientDto>(); foreach (var item in ingredient) { var dto = new IngredientDto(); dto.Id = item.Id; dto.Name = item.Name; dto.IsChecked = Convert.ToBoolean(item.IsChecked); viewitems.Add(dto); } return(PartialView("_GetItem", viewitems)); }
// GET: Ingredients public ActionResult Index() { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Login", null)); } int recipeID = Convert.ToInt32(Session["RecipeID"]); var ingredient = _ingredientRepository.GetIngredientByRecipe(recipeID); var viewitems = new List <IngredientDto>(); viewitems.Add(new IngredientDto()); foreach (var item in ingredient) { var dto = new IngredientDto(); dto.Id = item.Id; dto.Name = item.Name; dto.IsChecked = Convert.ToBoolean(item.IsChecked); dto.RecipeId = item.RecipeId; viewitems.Add(dto); } return(View(viewitems)); }