public IActionResult Save(Models.PostEditModel model) { // Validate if (string.IsNullOrWhiteSpace(model.Title)) { ErrorMessage("The post could not be saved. Title is mandatory", false); return(View("Edit", model.Refresh(api))); } if (string.IsNullOrWhiteSpace(model.SelectedCategory)) { ErrorMessage("The post could not be saved. Category is mandatory", false); return(View("Edit", model.Refresh(api))); } var ret = model.Save(api, out var alias); // Save if (ret) { if (!string.IsNullOrWhiteSpace(alias)) { TempData["AliasSuggestion"] = alias; } SuccessMessage("The post has been saved."); return(RedirectToAction("Edit", new { id = model.Id })); } else { ErrorMessage("The post could not be saved.", false); return(View("Edit", model.Refresh(api))); } }
public IActionResult Publish(Models.PostEditModel model) { // Validate if (string.IsNullOrWhiteSpace(model.Title)) { ErrorMessage("The post could not be saved. Title is mandatory", false); return(View("Edit", model.Refresh(api))); } if (string.IsNullOrWhiteSpace(model.SelectedCategory)) { ErrorMessage("The post could not be saved. Category is mandatory", false); return(View("Edit", model.Refresh(api))); } // Save if (model.Save(api, true)) { SuccessMessage("The post has been published."); return(RedirectToAction("Edit", new { id = model.Id })); } else { ErrorMessage("The post could not be published.", false); return(View(model)); } }