Exemplo n.º 1
0
        public ActionResult CreateComment(Comment c, int? id)
        {
            // Geyma 'id' svo hægt sé að nálgast það í 'View-inu'
            ViewBag.folderid = id;

            // Sækja notendanafn þess sem er innskráður
            string usr = System.Web.HttpContext.Current.User.Identity.Name;

            // Öryggisráðstafanir
            if (usr == null || c.CommentText == null)
            {
                return RedirectToAction("Details", new { ID = id });
            }
            else
            {
                // Tengja athugasemdina við möppu og notanda
                c.FolderID = ViewBag.folderid;
                c.UserName = usr;

                // Setja athugasemdina í gagnagrunninn og vista breytingar
                repo.AddComment(c);
                repo.Save();

                // Fara til baka á síðuna þar sem athugasemdin var skráð
                return RedirectToAction("Details", new { ID = id });
            }
        }
Exemplo n.º 2
0
 // Add comment 'c' to the database
 // Used in FolderController
 public void AddComment(Comment c)
 {
     db.Comments.Add(c);
 }