public IActionResult DisplayFullBlogPost() { Comments comment = new Models.Comments(); comment.BlogPostId = Convert.ToInt32(Request.Form["BlogPostId"]); comment.UserId = Convert.ToInt32(HttpContext.Session.GetInt32("UserId")); comment.Content = Request.Form["Content"]; _assignContext.Comments.Add(comment); _assignContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Insert(Models.Comments objComment) { try { clsDataBaseMethodsComments objDB = new clsDataBaseMethodsComments(); objDB.Insert(objComment); TempData["Success"] = "¡Comment Created!"; return(RedirectToAction("Index", "Comments", new { id = objComment.intPostId })); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(objComment)); }
public ActionResult Insert(string id) { if (TempData["Error"] != null && !String.IsNullOrEmpty(TempData["Error"].ToString())) { ViewBag.Error = TempData["Error"].ToString(); } if (TempData["Success"] != null && !String.IsNullOrEmpty(TempData["Success"].ToString())) { ViewBag.Success = TempData["Success"].ToString(); } var model = new Models.Comments(); model.intPostId = Convert.ToInt32(id); return(View(model)); }
public ActionResult Index(string id) { CultureInfo en = new CultureInfo("es-CO"); Thread.CurrentThread.CurrentCulture = en; if (TempData["Error"] != null && !String.IsNullOrEmpty(TempData["Error"].ToString())) { ViewBag.Error = TempData["Error"].ToString(); } if (TempData["Success"] != null && !String.IsNullOrEmpty(TempData["Success"].ToString())) { ViewBag.Success = TempData["Success"].ToString(); } var model = new Models.Comments(); model.intPostId = Convert.ToInt32(id); return(View(model)); }
public IActionResult AddComment() { Comments com = new Models.Comments(); com.UserId = Convert.ToInt32(HttpContext.Session.GetString("UserId")); com.BlogPostId = Convert.ToInt32(Request.Form["BlogPostId"]); com.Rating = Convert.ToInt32(Request.Form["Comment.Rating"]); com.Content = Request.Form["Comment.Content"]; var badwordList = _Assignment2DataContext.BadWords.ToList(); foreach (var word in badwordList) { if (com.Content.Contains(word.Word)) { com.Content = com.Content.Replace(word.Word, "*****"); } } _Assignment2DataContext.Comments.Add(com); _Assignment2DataContext.SaveChanges(); return(RedirectToAction("Index")); }
public List<Comments> AllComments() { List<Comments> comList = new List<Models.Comments>(); ISingleResult<ShowAllCommentsResult> data = dataDB.ShowAllComments(); foreach (var res in data) { Comments Comments = new Models.Comments(); Comments.ShowName = res.ComName; Comments.ShowDate = res.time.ToString(); Comments.ShowComments = res.ComComments; comList.Add(Comments); } return comList; }