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