private ActionResult SavePost(ModelStateDictionary model, IBasePostService service, BasePostVM viewModel, string userEmail, string viewName, string redirectAction, string returnUrl) { if (!model.IsValid) { service.PopulateCategories(viewModel); return(View(viewName, viewModel)); } var postId = service.SavePost(viewModel, userEmail); if (postId == null) { return(View("Error")); } if (returnUrl != null) { return(Redirect(returnUrl)); } else { var encryptedPostId = Encryptor.GetEncryptedString(postId.ToString()); return(RedirectToAction(redirectAction, "Ad", new { _currentPostId = encryptedPostId })); } }
private ActionResult EditPost(IBasePostService service, string postId, string userEmail, string viewName, BasePostVM viewModel) { if (!service.GetPostVMById(postId, userEmail, viewModel)) { return(View("Error")); } return(View(viewName, viewModel)); }
public ActionResult DeletePost(IBasePostService service, string currentPostId, string returnUrl, string userEmail) { if (!service.DeletePost(currentPostId, userEmail)) { return(View("Error")); } if (!Url.IsLocalUrl(returnUrl)) { return(View("Error")); } return(ReturnTo(returnUrl)); }