public void AddComment(Comment comment) { var model = (from m in m_subtitles where m.Id == comment.SubtitleId select m).SingleOrDefault(); model.Comments.Add(comment); }
public void AddComment(Comment comment) { var theSubtitle = (from c in m_db.Subtitles where c.Id == comment.SubtitleId select c).SingleOrDefault(); theSubtitle.Comments.Add(comment); m_db.SaveChanges(); }
public ActionResult AddComment(Comment comment) { string userId = User.Identity.GetUserId(); DateTime timi = DateTime.Now; Comment newComment = new Comment { UserId = userId, SubtitleId = comment.SubtitleId, CommentText = comment.CommentText, DateSubmitted = timi }; m_repo.AddComment(newComment); return Json("", JsonRequestBehavior.AllowGet); }
public ActionResult TestAddComment(string comment, int? subtitleid) { if (subtitleid.HasValue && !String.IsNullOrEmpty(comment)) { DateTime timi = DateTime.Now; Comment newComment = new Comment { SubtitleId = subtitleid.Value, CommentText = comment, DateSubmitted = timi }; return View(newComment); } else if (!subtitleid.HasValue) { return View("Error"); } else { ModelState.AddModelError("comment", "Commenttext cannot be empty!"); return View("Error"); } }