public ActionResult Delete(int id) { Thread thread = this.GetThread(id); if (thread == default(Thread) || thread.IsDeleted) { return(this.RedirectToAction("BadRequest", "Error")); } DeleteThreadBindingModel deleteThread = new DeleteThreadBindingModel() { Id = thread.ThreadId, Title = thread.Title }; return(this.View(deleteThread)); }
public ActionResult Delete(int id, DeleteThreadBindingModel model) { Thread deleteThread = this.GetThread(id); if (deleteThread == default(Thread) || deleteThread.IsDeleted || id != model.Id) { return(this.RedirectToAction("BadRequest", "Error")); } if (!this.ModelState.IsValid) { return(this.RedirectToAction("BadRequest", "Error")); } deleteThread.IsDeleted = true; this.UnitOfWork .ThreadRepository .Update(deleteThread); this.UnitOfWork.SaveChanges(); return(this.RedirectToAction("Home", "Home")); }