public async Task <ActionResult> Editar(string boton, EditorBorrador viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } await ActualizarBorrador(viewModel); if (boton.ToLower().Contains(@"publicar")) { var editorPost = new EditorPost(viewModel); TryValidateModel(editorPost); if (!ModelState.IsValid) { return(View(viewModel)); } return(RedirectToAction("Publicar", "Posts", new { id = viewModel.Id })); } return(RedirectToAction("Detalles", new { id = viewModel.Id })); }
private async Task ActualizarPost(EditorPost editorPost) { var post = await RecuperarPost(editorPost.Id); ActualizaPost(post, editorPost, _asignadorTags); await _db.GuardarCambios(); }
public async Task <ActionResult> Publicar(string boton, PublicarPost viewModel) { string accion = boton.ToLower(); var post = await RecuperarPost(viewModel.Id); if (accion.Contains("cancelar")) { if (post.EsBorrador) { return(RedirectToAction("Editar", "Borradores", new { id = viewModel.Id })); } return(RedirectToAction("Edit", "Posts", new { id = viewModel.Id })); } if (ModelState.IsValid) { var editorPost = new EditorPost(post); TryValidateModel(editorPost); if (!ModelState.IsValid) { return(View(viewModel)); } if (accion.Contains("programar")) { await ProgramarPublicacion(viewModel); } else if (accion.Contains("publicar")) { await PublicarPost(viewModel); } LimpiarCache(); if (accion.Contains("programar")) { return(RedirectToAction("Index", "Borradores")); } if (accion.Contains("home")) { return(RedirectToAction("Index", "Blog")); } return(RedirectToRoute(RouteConfig.NombreRutaAmigable, new { urlSlug = viewModel.UrlSlug })); } return(View(viewModel)); }
public static void ActualizaPost(Post post, EditorPost editorPost, AsignadorTags asignadorTags) { post.ModificarTitulo(editorPost.Titulo); post.Subtitulo = editorPost.Subtitulo; post.Descripcion = editorPost.Descripcion; post.Autor = editorPost.Autor; post.ContenidoHtml = editorPost.ContenidoHtml; post.PalabrasClave = editorPost.PalabrasClave; post.UrlImagenPrincipal = editorPost.UrlImagenPrincipal; asignadorTags.AsignarTags(post, editorPost.ListaTags); post.FechaModificacion = DateTime.Now; }
public static void CopiaValores(this Modelo.Posts.Post post, EditorPost editorPost, AsignadorTags asignadorTags) { post.InjectFrom(editorPost); asignadorTags.AsignarTags(post, editorPost.ListaTags); }