public void DeleteC(Comments c) { CommentsDB db = new CommentsDB(); db.Delete(c); db.SaveChanges(); }
public IActionResult seePost(string textBox, CommentsDB list, int submit, string user, string btnSubmit, int commentId) { if (btnSubmit != null) { switch (btnSubmit) { case "editPost": return(RedirectToAction("editPost", new { Id = submit })); case "deletePost": list.deletePost(submit); return(RedirectToAction("seePost", new { submit = submit })); case "editComment": return(RedirectToAction("editComment", new { Id = commentId })); case "deleteComment": list.deleteComment(commentId); return(RedirectToAction("seePost", new { submit = submit })); } } if (textBox != null && user != null) { list.addComment(submit, user, textBox); } else { Models.ErrorViewModel error = new Models.ErrorViewModel(); error.RequestId = "Create comment error, one of the required values was empty"; return(View("Error", error)); } return(RedirectToAction("seePost", new { submit = submit })); }
public IActionResult seePost(int submit, CommentsDB list) { ViewBag.PostId = submit; IEnumerable <CommentsDB> dataofComments = list.getCommentsDB(submit).OrderBy(x => x.Date); return(View(dataofComments)); }
public CommentsList SelectCbyP(Person p) { CommentsDB db = new CommentsDB(); CommentsList l = new CommentsList(); l = db.CommentsByPerson(p); return(l); }
public CommentsList SelectAllC() { CommentsDB db = new CommentsDB(); CommentsList l = new CommentsList(); l = db.SelectAll(); return(l); }
protected void Page_Load(object sender, EventArgs e) { recipeDB = new RecipeDB(); RecipeID = int.Parse(Request.QueryString["RecipeID"]); if (!this.IsPostBack) { if (Request.UrlReferrer != null && !new RecipeDB().isCook(RecipeID, User.Identity.Name)) { if (!(Request.UrlReferrer.Query.Contains(HttpContext.Current.Request.Url.PathAndQuery) || Request.UrlReferrer.AbsoluteUri == Request.Url.AbsoluteUri)) recipeDB.IncreaseView(RecipeID); } } DataTable CommentsTable = new CommentsDB().GetComments(RecipeID); DataView CommentsView = new DataView(CommentsTable); if (CommentsTable.Rows.Count != 0) { CommentsView.Sort = "PostedTime DESC"; CommentsRepeater.DataSource = CommentsView; CommentsRepeater.DataBind(); CommentsRepeater.Visible = true; NoCommentsLabel.Visible = false; } else { NoCommentsLabel.Visible = true; CommentsRepeater.Visible = false; } if (Membership.GetUser() != null) CommentView.SetActiveView(LoggedUserView); else CommentView.SetActiveView(NoUserView); ClickHere.NavigateUrl = @"~\Account\Login.aspx?ReturnUrl=" + Page.Request.RawUrl; }
public IActionResult editcomment(int submit, string textBox, int postId, CommentsDB com) { com.updateComment(submit, textBox); return(RedirectToAction("seePost", new { submit = postId }));; }
public IActionResult editcomment(int Id, CommentsDB com) { IEnumerable <CommentsDB> comObj = com.getCommentById(Id); return(View(comObj)); }