public async Task <IActionResult> Edit(int id, [Bind("RecipeCommentsId,Comments,UserProfileId,RecipeId")] RecipeComments recipeComments) { if (id != recipeComments.RecipeCommentsId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recipeComments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeCommentsExists(recipeComments.RecipeCommentsId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["RecipeId"] = new SelectList(_context.Recipe, "RecipeId", "RecipeText", recipeComments.RecipeId); ViewData["UserProfileId"] = new SelectList(_context.UserProfile, "UserProfileId", "FirstName", recipeComments.UserProfileId); return(View(recipeComments)); }
//Handles recipe comment private void GetComments() { //Get Recipe Comment - show/hide comment RecipeComments Comment = new RecipeComments(Recipe.ID, RecComments, PlaceHolder1); Comment.fillup(); Comment = null; }
public async Task <IActionResult> Create([Bind("RecipeCommentsId,Comments,UserProfileId,RecipeId")] RecipeComments recipeComments) { if (ModelState.IsValid) { _context.Add(recipeComments); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RecipeId"] = new SelectList(_context.Recipe, "RecipeId", "RecipeText", recipeComments.RecipeId); ViewData["UserProfileId"] = new SelectList(_context.UserProfile, "UserProfileId", "FirstName", recipeComments.UserProfileId); return(View(recipeComments)); }