public ActionResult Page(string ids) { Advertisement aModel = new Advertisement(); Session["AdverId"] = null; List <Advertisement> adver = aModel.AdvertisementId(Convert.ToInt32(ids)); Session["AdverId"] = adver; Comment cModel = new Comment(); List <Comment> cList = cModel.CommentId(Convert.ToInt32(ids)); ViewBag.commentList = cList; return(View("Page")); }
public ActionResult CommentAdd(string AdvertisementId, string sender, string CommentText) { foreach (Advertisement item in (List <Advertisement>)Session["AdverId"]) { AdvertisementId = item.id.ToString(); } if (String.IsNullOrWhiteSpace(CommentText)) { ViewData["message"] = "Write a comment before submiting"; } else { CommentLogic cLogic = new CommentLogic(); cLogic.CommentAdd(Convert.ToInt32(AdvertisementId), Session["username"].ToString(), CommentText, DateTime.Now); Comment cModel = new Comment(); List <Comment> cList = cModel.CommentId(Convert.ToInt32(AdvertisementId)); ViewBag.commentList = cList; } return(View("Page")); }