public void Update(User_Post UserPost) { User_Post uPost = this.context.User_Post.SingleOrDefault(x => x.Id == UserPost.Id && x.userID == UserPost.userID); uPost.postHeadline = UserPost.postHeadline; uPost.postContent = UserPost.postContent; }
public ActionResult PostDetails(int id) { User_Post post = posts.GetSingle(id); ViewBag.postId = post.Id; ViewBag.postHead = post.postHeadline; ViewBag.postCont = post.postContent; ViewBag.postPic = post.postPicture; ViewBag.date = post.postDate; ViewBag.userID = post.userID; ViewBag.userName = users.GetSingle(post.userID).fullName; IEnumerable <User_Comment> commentList = comments.GetComments(id); List <UserPostCommentModel> fullCommentDetailList = new List <UserPostCommentModel>(); foreach (User_Comment c in commentList) { UserPostCommentModel fullCommentDetail = new UserPostCommentModel(); fullCommentDetail.Id = c.Id; fullCommentDetail.CommentContent = c.commentContent; fullCommentDetail.postId = id; fullCommentDetail.commentDate = c.commentDate; fullCommentDetail.userId = c.userID; fullCommentDetail.userName = users.GetSingle(c.userID).fullName; fullCommentDetail.userProPic = Url.Content(users.GetSingle(c.userID).profilePicture); fullCommentDetailList.Add(fullCommentDetail); } ViewBag.userID = Session["UserID"]; ViewBag.userName = Session["UserName"]; ViewBag.logged = Session["loggedOn"]; return(View(fullCommentDetailList)); }
public ActionResult newPost(HttpPostedFileBase picture) { if (Request.Form["postBtn"] != null) { if (picture != null && picture.ContentLength > 0) { var filename = Path.GetFileName(picture.FileName); var path = Path.Combine(Server.MapPath("~/images"), filename); picture.SaveAs(path); User_Post post = new User_Post(); post.postHeadline = Request.Form["headLineName"]; post.postContent = Request.Form["bodyName"]; post.postPicture = "~/images/" + filename.ToString(); post.postDate = DateTime.Now.Date; post.userID = Convert.ToInt32(Session["UserID"]); posts.Insert(post); return(RedirectToAction("Index", "BlogHome")); } else { return(RedirectToAction("Index", "Home")); } } else { return(View("Index", "Home")); } }
public void DeleteSingle(int id) { User_Post uPost = this.context.User_Post.SingleOrDefault(x => x.Id == id); this.context.User_Post.Remove(uPost); this.context.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { User_Post user_Post = db.All_Posts.Find(id); db.All_Posts.Remove(user_Post); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,PostedOn,Title,Discription,Voted_Count,Answered_Count,Acceptance_Of_Post,Post_Type,Associated_User_Id")] User_Post user_Post) { if (ModelState.IsValid) { db.Entry(user_Post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_Post)); }
public ActionResult Create([Bind(Include = "Id,PostedOn,Title,Discription,Voted_Count,Answered_Count,Acceptance_Of_Post,Post_Type,Associated_User_Id")] User_Post user_Post) { if (ModelState.IsValid) { db.All_Posts.Add(user_Post); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_Post)); }
// GET: User_Post/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Post user_Post = db.All_Posts.Find(id); if (user_Post == null) { return(HttpNotFound()); } return(View(user_Post)); }
public void Insert(User_Post User_Post) { this.context.User_Post.Add(User_Post); this.context.SaveChanges(); }
public void Update(User_Post User_Post) { this.data.Update(User_Post); }
public void Insert(User_Post User_Post) { this.data.Insert(User_Post); }