// GET: Blog/Delete/5 public ActionResult Delete(int id) { Models.post posts = unitOfWork.PostRepository.GetByID(id); posts.is_active = false; unitOfWork.PostRepository.SoftDelete(id); unitOfWork.Save(); return(RedirectToAction("Index")); }
public ActionResult Edit(Models.post posts) { try { if (ModelState.IsValid) { unitOfWork.PostRepository.Update(posts); unitOfWork.Save(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name after DataException and add a line here to write a log.) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } CategorysDropDownList(posts.id_category); return(View(posts)); }
public string retrieveAPostWithComments(int postId) { try { Models.post postFound = PostsList.Find(x => x.id.Equals(postId)); if (postFound is null) { return(string.Empty); } string partial = JsonConvert.SerializeObject(postFound); var commentsFound = CommentsList.Find(x => x.postId.Equals(postId)); string comments = JsonConvert.SerializeObject(commentsFound); if (!(comments is null)) { comments = string.Empty; } return(string.Format("Post:{0} \\r\\n Comments:{1}", partial, comments)); } catch { return(null); } }
// GET: Blog/Edit/5 public ActionResult Edit(int id) { Models.post posts = unitOfWork.PostRepository.GetByID(id); CategorysDropDownList(posts.id_category); return(View(posts)); }
// GET: Blog/Details/5 public ActionResult Details(int id) { Models.post posts = unitOfWork.PostRepository.GetByID(id); return(View(posts)); }