public static CommentNewsViewModel Map(CommentNews model) { var viewModel = mapper.Map(model); viewModel.Comment = SingleCommentMapper.Map(model.Comment); return(viewModel); }
public void DeleteCommend(int id) { CommentNews conew = db.CommentNews.Single(p => p.CommentNews_id == id); db.CommentNews.Remove(conew); db.SaveChanges(); }
private void CreateNews(int userId, int commentId) { var news = new CommentNews(); news.UserId = userId; news.EntityId = commentId; context.CommentNewsStorage.Add(news); }
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)); }
public void UpdateCommend(CommentNews commnews) { db.Entry <CommentNews>(commnews).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void AddComment(CommentNews commnews) { commnews.CommentTime = DateTime.Now; db.CommentNews.Add(commnews); db.SaveChanges(); }
public static void UpdateCommend(CommentNews commnews) { commentnews.UpdateCommend(commnews); }
public static void AddComment(CommentNews commnews) { commentnews.AddComment(commnews); }
public static bool CommentNews_Update(CommentNews data) { return(db.CommentNews_Update(data)); }
public static bool CommentNews_Insert(CommentNews data) { return(db.CommentNews_Insert(data)); }