Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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"));
        }