public ActionResult Create([Bind(Include = "Id,Name,Comments")] tblComment tblComment) { StringBuilder sbComments = new StringBuilder(); // Encode the text that is coming from comments textbox sbComments.Append(HttpUtility.HtmlEncode(tblComment.Comments)); // Only decode bold and underline tags sbComments.Replace("<b>", "<b>"); sbComments.Replace("</b>", "</b>"); sbComments.Replace("<u>", "<u>"); sbComments.Replace("</u>", "</u>"); tblComment.Comments = sbComments.ToString(); // HTML encode the text that is coming from name textbox string strEncodedName = HttpUtility.HtmlEncode(tblComment.Name); tblComment.Name = strEncodedName; if (ModelState.IsValid) { db.tblComments.Add(tblComment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblComment)); }
public ActionResult DeleteConfirmed(int id) { tblComment tblComment = db.tblComments.Find(id); db.tblComments.Remove(tblComment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult dell(int id) { tblComment c = dt.tblComments.Single(v => v.iD.Equals(id)); dt.tblComments.Remove(c); dt.SaveChanges(); Response.Write(1); return(null); }
public ActionResult Edit([Bind(Include = "Id,Name,Comments")] tblComment tblcomment) { if (ModelState.IsValid) { db.Entry(tblcomment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblcomment)); }
public ActionResult Edit([Bind(Include = "CommentsId,TicketId,Name,Comments")] tblComment tblComment) { if (ModelState.IsValid) { db.Entry(tblComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TicketId = new SelectList(db.tblTickets, "TicketId", "Name", tblComment.TicketId); return(View(tblComment)); }
public ActionResult Edit([Bind(Include = "CommentId,PostId,CommentBody,NameOfUser")] tblComment tblComment) { if (ModelState.IsValid) { db.Entry(tblComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PostId = new SelectList(db.tblPosts, "PostId", "PostTitle", tblComment.PostId); return(View(tblComment)); }
public ActionResult Edit([Bind(Include = "Comment_ID,Comment_Contents,Comment_User,Comment_Post,Comment_DatePost")] tblComment tblComment) { if (ModelState.IsValid) { db.Entry(tblComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Comment_Post = new SelectList(db.tblPosts, "Post_ID", "Post_Title", tblComment.Comment_Post); ViewBag.Comment_User = new SelectList(db.tblUsers, "User_ID", "User_DisplayName", tblComment.Comment_User); return(View(tblComment)); }
public ActionResult Edit([Bind(Include = "ID,ID_User,ID_Local,Comment")] tblComment tblComment) { if (ModelState.IsValid) { db.Entry(tblComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_Local = new SelectList(db.tblLocals, "ID", "Name", tblComment.ID_Local); ViewBag.ID_User = new SelectList(db.tblUsers, "ID", "ID", tblComment.ID_User); return(View(tblComment)); }
public ActionResult Edit([Bind(Include = "Id,ParentId,News,Name,Email,PhoneNumber,Content,Status,CreateDate,ModifyDate")] tblComment tblComment) { if (ModelState.IsValid) { db.Entry(tblComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ParentId = new SelectList(db.tblComments, "Id", "Name", tblComment.ParentId); ViewBag.News = new SelectList(db.tblNews, "Id", "Titles", tblComment.News); return(View(tblComment)); }
public async Task <CommentModel> UpdateComment(CommentModel model) { try { tblComment data = await Task.Run(() => ManageComments.UpdateComment(model.ConvertTotblComment())); return(data.ConvertToComment()); } catch (Exception) { throw; } }
public async Task <CommentModel> InsertComment(CommentModel data) { try { tblComment res = await Task.Run(() => ManageComments.InsertComment(data.ConvertTotblComment())); return(res.ConvertToComment()); } catch (Exception) { throw; } }
// GET: Comment/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } return(View(tblComment)); }
public ActionResult DeleteConfirmed(long id) { if (IsLogin()) { tblComment tblComment = db.tblComments.Find(id); db.tblComments.Remove(tblComment); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult Create([Bind(Include = "Comment_ID,Comment_Contents,Comment_User,Comment_DatePost,Comment_Blog,Comment_Post,Comment_Trash")] tblComment tblComment) { if (ModelState.IsValid) { db.tblComments.Add(tblComment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Comment_Blog = new SelectList(db.tblBlogs, "BLog_ID", "Blog_Title", tblComment.Comment_Blog); ViewBag.Comment_Post = new SelectList(db.tblPosts, "Post_ID", "Post_Title", tblComment.Comment_Post); ViewBag.Comment_User = new SelectList(db.tblUsers, "User_ID", "User_DisplayName", tblComment.Comment_User); return(View(tblComment)); }
public ActionResult chat(FormCollection fc) { tblComment c = new tblComment(); c.cContent = fc["msg-box"]; c.iContent = Convert.ToInt32(fc["id"]); c.iCreateBy = Get_ID(); c.dCreateDate = DateTime.Now; dt.tblComments.Add(c); dt.SaveChanges(); string data = "<p id=\"tr_" + c.iD + "\" class=\"user-linda\" style=\"display: block;\"><span class=\"msg-block\"><strong>" + dt.tblUsers.Single(v => v.iD.Equals((int)c.iCreateBy)).cName + "</strong> <span class=\"time\">" + Convert.ToDateTime(c.dCreateDate).Hour + ":" + Convert.ToDateTime(c.dCreateDate).Minute + " (" + func.ConvertDateVN(Convert.ToDateTime(c.dCreateDate).ToShortDateString()) + ") <a href=\"javascript:void()\" onclick=\"DeletePage(" + c.iD + ",'id=" + c.iD + "','/content/dell')\"><i class=icon-trash style=color: red;></i></a></span><span class=\"msg\">" + c.cContent + "</span></span></p>"; Response.Write(data); return(null); }
// GET: Comment/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } ViewBag.TicketId = new SelectList(db.tblTickets, "TicketId", "Name", tblComment.TicketId); return(View(tblComment)); }
// GET: Comments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } ViewBag.ID_Local = new SelectList(db.tblLocals, "ID", "Name", tblComment.ID_Local); ViewBag.ID_User = new SelectList(db.tblUsers, "ID", "ID", tblComment.ID_User); return(View(tblComment)); }
public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } ViewBag.ParentId = new SelectList(db.tblComments, "Id", "Name", tblComment.ParentId); ViewBag.News = new SelectList(db.tblNews, "Id", "Titles", tblComment.News); return(View(tblComment)); }
public async Task <CommentModel> GetComment(long Id) { try { CommentModel model = null; tblComment data = await Task.Run(() => ManageComments.GetComment(Id)); model = data.ConvertToComment(); return(model); } catch (Exception) { throw; } }
public static CommentModel ConvertToComment(this tblComment data) { return(new CommentModel() { id = data.ID, comment = data.Comment, showToAll = data.ShowToAll, isActive = data.IsActive, isDeleted = data.IsDeleted, createdUserID = data.CreatedUserID, updatedUserID = data.UpdatedUserID, createdTimestamp = data.CreatedTimestamp, updatedTimestamp = data.UpdatedTimestamp, commentUser = data.tblCommentUsers?.Select(x => x.ConvertToCommentUsers()).ToList() }); }
public int AddComment(CommentModel objCommentModel) { tblComment objtblComment = new tblComment(); objtblComment.Comment_Text = objCommentModel.Comment_Text; objtblComment.Comment_Date = DateTime.Now; objtblComment.Comment_Email = objCommentModel.Comment_Email; objtblComment.Comment_By = objCommentModel.Comment_By; objtblComment.Blog_Id = objCommentModel.Blog_Id; objtblComment.Isapproved = 0; dbentity.tblComments.Add(objtblComment); dbentity.SaveChanges(); int id = objtblComment.Comment_Id; return(id); }
// GET: Comments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } ViewBag.Comment_Post = new SelectList(db.tblPosts, "Post_ID", "Post_Title", tblComment.Comment_Post); ViewBag.Comment_User = new SelectList(db.tblUsers, "User_ID", "User_DisplayName", tblComment.Comment_User); return(View(tblComment)); }
internal static async Task DeleteComment(long Id) { try { using (db = new eMSPEntities()) { tblComment obj = await db.tblComments.FindAsync(Id); db.tblComments.Remove(obj); int x = await Task.Run(() => db.SaveChangesAsync()); } } catch (Exception) { throw; } }
public bool DeleteById(short id) { using (var db = new ModelDbContext()) { if (!db.tblComments.Any(p => p.Id == id)) { return(false); } var item = new tblComment() { Id = id }; db.tblComments.Attach(item); db.tblComments.Remove(item); return(db.SaveChanges() > 0); } }
internal static async Task <tblComment> UpdateComment(tblComment model) { try { using (db = new eMSPEntities()) { db.Entry(model).State = EntityState.Modified; int x = await Task.Run(() => db.SaveChangesAsync()); return(model); } } catch (Exception) { throw; } }
// GET: tblComments/Details/5 public ActionResult Details(int?id) { if (Session["EmailId"] == null) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } return(View(tblComment)); }
public ActionResult Create([Bind(Include = "ID,ID_User,ID_Local,Comment")] tblComment tblComment) { tblComment.ID_User = User.Identity.GetUserId(); int idL = Convert.ToInt32(TempData["idL"]);//податокот се зема од RatingsController tblComment.ID_Local = idL; tblComment.Date = DateTime.Now.Date; if (ModelState.IsValid) { db.tblComments.Add(tblComment); db.SaveChanges(); return(RedirectToAction("Index", "Visits")); } ViewBag.ID_Local = new SelectList(db.tblLocals, "ID", "Name", tblComment.ID_Local); ViewBag.ID_User = new SelectList(db.tblUsers, "ID", "ID", tblComment.ID_User); return(View(tblComment)); }
internal static async Task <tblComment> InsertComment(tblComment model) { try { using (db = new eMSPEntities()) { model = db.tblComments.Add(model); int x = await Task.Run(() => db.SaveChangesAsync()); return(model); } } catch (Exception ex) { throw; } }
// GET: tblComments/Edit/5 public ActionResult Edit(int?id) { if (Session["EmailId"] == null) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblComment tblComment = db.tblComments.Find(id); if (tblComment == null) { return(HttpNotFound()); } ViewBag.PostId = new SelectList(db.tblPosts, "PostId", "PostTitle", tblComment.PostId); return(View(tblComment)); }
public bool UpdateStatus(short id, short status) { using (var db = new ModelDbContext()) { var item = new tblComment() { Id = id }; if (db.tblComments.Any(p => p.Id == id)) { db.tblComments.Attach(item); item.Status = status; } else { return(false); } return(db.SaveChanges() > 0); } }