public ActionResult Altera(Post post) { if (!ModelState.IsValid) { HttpContext.Response.StatusCode = 400; return(View("Detalhe", post)); } if (post.Publicado && (post.DataPublicacao == null)) { post.DataPublicacao = DateTime.Now; } else if (!post.Publicado && (post.DataPublicacao != null)) { post.DataPublicacao = null; } _dao.Alterar(post); return(RedirectToAction("Index")); }