Esempio n. 1
0
        public ActionResult AddComment(int? id, string commentText)
        {
            // í gagnagrunn fyrir
            if (!User.Identity.IsAuthenticated)                     // ákveðið TranslationID
            {
                Response.StatusCode = 404;
                return Json(null, JsonRequestBehavior.DenyGet);     // Deny ef user er ekki innskráður
            }
            Comment comment = new Comment();                        // Byr til tilvik af comment og
            UpdateModel(comment);                                   // og gefur thvi rétt gildi,
            comment.CommentText = commentText;                      // addar svo í gagnagrunn
            comment.TranslationID = id.Value;                       // og skilar json
            comment.UserName = User.Identity.Name;
            comment.commentDate = DateTime.Now;
            CommentRepo.AddComment(comment);

            return Json(comment, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
 public void AddComment(Comment c)
 {
     m_db.Comments.Add(c);
     m_db.SaveChanges();
 }