示例#1
0
        public ResponseModel AddComments(AddComments comment)
        {
            var news = _newsService.GetoneNews(comment.NewsId);

            if (news.code == 0)
            {
                return new ResponseModel {
                           code = 0, result = "评价的新闻不存在"
                }
            }
            ;
            var com = new NewsComment {
                AddTime = DateTime.Now, NewsId = comment.NewsId, Contents = comment.Contents
            };

            _db.NewsComment.Add(com);
            int i = _db.SaveChanges();

            if (i > 0)
            {
                return(new ResponseModel {
                    code = 200, result = "评论添加成功", data = new
                    {
                        contents = comment.Contents,
                        floor = '#' + news.data.CommentCount + 1,
                        addTime = DateTime.Now
                    }
                });
            }

            return(new ResponseModel {
                code = 0, result = "评论添加失败"
            });
        }
示例#2
0
        public ActionResult AddComments(int SHId, int studentId)
        {
            AddComments item = new AddComments();

            item.StudentID = studentId;
            item.SHomeID   = SHId;
            return(View(item));
        }
        public void just_empty_lines()
        {
            var ac       = new AddComments();
            var result   = ac.Transform(" \n   \t    \n");
            var expected = " \n   \t    \n";

            Assert.AreEqual(expected, result);
        }
        public void three_lines_with_one_empty()
        {
            var ac       = new AddComments();
            var result   = ac.Transform("aaa\nbbb\n");
            var expected = "// aaa\n// bbb\n";

            Assert.AreEqual(expected, result);
        }
示例#5
0
 public JsonResult AddComment(AddComments comment)
 {
     if (comment.NewsId <= 0)
     {
         return(Json(new ResponseModel {
             code = 0, result = "新闻不存在"
         }));
     }
     if (string.IsNullOrEmpty(comment.Contents))
     {
         return(Json(new ResponseModel {
             code = 0, result = "新闻不存在"
         }));
     }
     return(Json(_commentService.AddComments(comment)));
 }
        public void two_lines()
        {
            var ac = new AddComments();

            var result = ac.Transform(new[] {
                "aaa",
                "bbb"
            });

            var expected = new[] {
                "// aaa",
                "// bbb"
            };

            CollectionAssert.AreEqual(expected, result);
        }
示例#7
0
        public ActionResult AddComments(AddComments item)
        {
            string comments  = item.Comments;
            int    sHid      = item.SHomeID;
            int    studentId = item.StudentID;

            if (comments != "")
            {
                StudentHomeworkServices service = new StudentHomeworkServices();
                service.AddComment(sHid, comments, studentId);
                return(RedirectToAction("MyStudents", "Teacher"));
            }
            else
            {
                ModelState.AddModelError("", "Please add a comment!");
            }
            return(View());
        }
        protected void AddCommentButton_Click(object sender, EventArgs e)
        {
            int?        myArticleId = Convert.ToInt32(DropDownAddComment.SelectedValue);
            AddComments comment     = new AddComments();

            if (myArticleId.HasValue && myArticleId > 0)
            {
                bool addSuccess = comment.AddComment(Convert.ToString(myArticleId), AddCommentAuthor.Text, AddComment.Text);
                if (addSuccess)
                {
                    string pageUrl = Request.RawUrl.ToString();
                    Response.Redirect(pageUrl);
                }
                else
                {
                    LabelAddStatus.Text = "Unable to add comment to database";
                }
            }
            else
            {
                LabelAddStatus.Text = "There is a problem with database.";
            }
        }
示例#9
0
        public void AddComments()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);

            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav      = new ActivitiesNav();
            var AddCommentsPage = new AddComments("STUDY-" + targetStudy, "Add Comment");

            Store.LoginAsUser(Users.Irbd);

            var studyForReview = new CCElement(By.LinkText(targetStudy));

            studyForReview.Click();

            ActionsNav.LnkAddComment.Click();
            AddCommentsPage.SwitchTo();
            AddCommentsPage.TxtComment.Value = "This is a public comment";
            AddCommentsPage.BtnOk.Click();
            AddCommentsPage.SwitchBackToParent();

            Wait.Until(h => new CCElement(By.LinkText("Comment Added")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Comment Added")).Exists, "Comment Added not found for:  " + targetStudy);
        }