コード例 #1
0
 public bool editComment(Comment edited)
 {
     Comment c = getCommentByID(edited.ID);
     if (c != null)
     {
         c.Body = edited.Body;
         c.DateInserted = edited.DateInserted;
         return db.SaveChanges() != 0;
     }
     return false;
 }
コード例 #2
0
        public ActionResult CreateComment(FormCollection collection)
        {
            Comment c = new Comment();
            c.Body = collection["commentText"];
            c.DateInserted = DateTime.Now;
            c.UserID = User.Identity.GetUserId();
            c.UserName = User.Identity.Name;
            c.StatusID = Convert.ToInt32(collection["statusID"]);
            c.CurrentLogedinUser = User.Identity.GetUserId();

            var status = statusService.getStatusByID(c.StatusID);
            c.StatusUserID = status.UserID;
            statusService.addComment(c);

            string url = this.Request.UrlReferrer.AbsoluteUri;
            return Redirect(url);
        }
コード例 #3
0
        public ActionResult EditComment(FormCollection collection)
        {
            int? id = Convert.ToInt32(collection["commentId"]);
            Comment currentComment = statusService.getCommentByID(id);
            Comment editComment = new Comment();
            editComment.ID = currentComment.ID;
            editComment.DateInserted = currentComment.DateInserted;
            editComment.Body = null;
            editComment.StatusUserID = currentComment.StatusUserID;
            editComment.CurrentLogedinUser = User.Identity.GetUserId();

            string commentTextboxId = "commentTextbox" + Convert.ToString(id);

            if (currentComment.Body != null)
            {
                editComment.Body = collection[commentTextboxId];
            }

            statusService.editComment(editComment);

            string url = this.Request.UrlReferrer.AbsoluteUri;
            return Redirect(url);
        }
コード例 #4
0
 public bool addComment(Comment toAdd)
 {
     db.Comments.Add(toAdd);
     return db.SaveChanges() != 0;
 }
コード例 #5
0
 public bool removeComment(Comment toDel)
 {
     db.Comments.Remove(toDel);
     return db.SaveChanges() != 0;
 }