public IActionResult AddComment(Comment comment) { try { var result = _recipeRepository.AddComment(comment); if (result == "success") { return(Ok(StatusCodes.Status200OK)); } } catch (Exception ex) { throw ex; } return(StatusCode(StatusCodes.Status500InternalServerError)); }
public ActionResult AddComment(CommentModel comment) { try { var commentToAdd = (Comment)comment; commentToAdd.Id = comment.Id; commentToAdd.UserId = User.Identity.GetUserId(); db.AddComment(commentToAdd); db.Save(); return(RedirectToAction("Details", "Recipe", new { id = comment.RecipeId })); } catch { return(RedirectToAction("Details", "Recipe", new { id = comment.RecipeId })); } }