public ActionResult Create() { var post = BlogEntidad.CrearNuevoPorDefecto(); var viewModel = new EditBlogViewModel { EditorBlog = new EditorBlog() }; viewModel.EditorBlog.CopiaValores(post); return View(viewModel); }
public async Task<ActionResult> Create(string boton, EditBlogViewModel viewModel) { if (ModelState.IsValid) { await CrearBlog(viewModel.EditorBlog); if(boton.ToLower().Contains(@"salir")) return RedirectToAction("Index"); return RedirectToAction("Edit", new { viewModel.EditorBlog.Id }); } return View(viewModel); }
public async Task<ActionResult> Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var blog = await RecuperarBlog(id.Value); if (blog == null) { return HttpNotFound(); } var viewModel = new EditBlogViewModel { EditorBlog = new EditorBlog() }; viewModel.EditorBlog.CopiaValores(blog); return View(viewModel); }
public async Task<ActionResult> Guardar(EditBlogViewModel viewModel) { if (ModelState.IsValid) { await ActualizarBlog(viewModel.EditorBlog); } return Content(string.Empty); }
public async Task<ActionResult> Edit(EditBlogViewModel viewModel) { if (ModelState.IsValid) { await ActualizarBlog(viewModel.EditorBlog); return RedirectToAction("Index"); } return View(viewModel); }