public async Task<ActionResult> New(EditModel model) { if (string.IsNullOrWhiteSpace(model.Title) || string.IsNullOrWhiteSpace(model.Body)) { ModelState.AddModelError("", "No field must be left blank."); return View(model); } var id = (await _pageService.AddPageAsync(model.Title, model.Body, User)).ToString(); return RedirectToAction("Edit", new { id = id, resultMessage = "The page has been published successfully." }); }
public async Task<ActionResult> Edit(EditModel model) { if (string.IsNullOrWhiteSpace(model.Title) || string.IsNullOrWhiteSpace(model.Body) || string.IsNullOrWhiteSpace(model.Id)) { ModelState.AddModelError("", "All forms must not be empty."); return View(model); } await _pageService.UpdatePageAsync(model.Id, model.Title, model.Body); return RedirectToAction("Edit", new { id = model.Id, resultMessage = "The page has been edited successfully." }); }