public ActionResult AddComment(string text, string obj, string IdUser = "******", string ObjectId = "1") { Comment com = new Comment(); com.Time = DateTime.Now; com.UserId = IdUser; com.ObjectType = obj; com.ObjectId = Convert.ToInt32(ObjectId); com.CommentText = text; db.Comments.Add(com); db.SaveChanges(); return RedirectToAction("Index", "Home"); }
public ActionResult RetCom(string objid, string objtype) { lock (locker) { List<Comment> s = new List<Comment>(); foreach (Comment q in db.Comments) { if (q.ObjectType == objtype && q.ObjectId == Convert.ToInt32(objid)) s.Add(q); } Comment com = new Comment(); com.ObjectType = objtype; com.ObjectId = Convert.ToInt16(objid); ViewBag.Comments = s; return PartialView("Comments", com); } return new EmptyResult(); }
public ActionResult AddCom(Comment model) { Comment com = new Comment(); com.Time = DateTime.Now; com.UserId = model.UserId; com.ObjectType = model.ObjectType; com.ObjectId = model.ObjectId; com.CommentText = model.CommentText; db.Comments.Add(com); db.SaveChanges(); return RedirectToAction("RetCom", "Home", new { objid = com.ObjectId, objtype = com.ObjectType }); }