예제 #1
0
        public static CommentNewsViewModel Map(CommentNews model)
        {
            var viewModel = mapper.Map(model);

            viewModel.Comment = SingleCommentMapper.Map(model.Comment);
            return(viewModel);
        }
예제 #2
0
        public void DeleteCommend(int id)
        {
            CommentNews conew = db.CommentNews.Single(p => p.CommentNews_id == id);

            db.CommentNews.Remove(conew);
            db.SaveChanges();
        }
예제 #3
0
        private void CreateNews(int userId, int commentId)
        {
            var news = new CommentNews();

            news.UserId   = userId;
            news.EntityId = commentId;
            context.CommentNewsStorage.Add(news);
        }
예제 #4
0
        public string AddCommentNews(CommentNews commnews, string newcontent, int id)
        {
            var useid = Convert.ToInt32(Session["User_id"]);


            if (newcontent != null && newcontent.Length > 0)
            {
                commnews.User_id = useid;
                commnews.News_id = id;
                commnews.Content = newcontent;
                CommentNewsManage.AddComment(commnews);
                return("success");
            }
            else
            {
                return("fail");
            }
        }
        public ActionResult SetComment(NewsCommentViewModel model)
        {
            if (ModelState.IsValid)
            {
                News Item = db.News.Find(model.DocId);

                var comment = new CommentNews {
                    Author = HttpContext.User.Identity.Name, Text = model.Text, News = Item
                };
                db.CommentsNews.Add(comment);
                var result = db.SaveChanges();

                if (result > 0)
                {
                    return(RedirectToAction("DisplayNews", "News", new { DocId = Item.Id }));
                }
            }
            return(View(model));
        }
예제 #6
0
 public void UpdateCommend(CommentNews commnews)
 {
     db.Entry <CommentNews>(commnews).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
예제 #7
0
 public void AddComment(CommentNews commnews)
 {
     commnews.CommentTime = DateTime.Now;
     db.CommentNews.Add(commnews);
     db.SaveChanges();
 }
예제 #8
0
 public static void UpdateCommend(CommentNews commnews)
 {
     commentnews.UpdateCommend(commnews);
 }
예제 #9
0
 public static void AddComment(CommentNews commnews)
 {
     commentnews.AddComment(commnews);
 }
예제 #10
0
 public static bool CommentNews_Update(CommentNews data)
 {
     return(db.CommentNews_Update(data));
 }
예제 #11
0
 public static bool CommentNews_Insert(CommentNews data)
 {
     return(db.CommentNews_Insert(data));
 }