public ActionResult Manage(PostBinder post) { if (!this.ModelState.IsValid) { ManageViewModel model = new ManageViewModel(); model.Post = post; model.Categories = this.categoryService.GetCategories(); return this.View(model); } try { this.postService.SaveOrUpdate(post.MapTo<PostDto>()); } catch (DexterException e) { this.Logger.Error("Error during saving the post", e); return this.urlBuilder.Admin.FeedbackPage(FeedbackType.Negative, "UnableToSaveThePost", null).Redirect(); } return this.urlBuilder.Admin.FeedbackPage(FeedbackType.Positive, "PostSaved", this.urlBuilder.Admin.Post.List()).Redirect(); }
public ActionResult Manage(int? id, int? month, int? day, int? year) { IList<CategoryDto> categories = this.categoryService.GetCategories(); PostBinder post = id.HasValue && id > 0 ? (this.postService.GetPostByKey(id.Value)).MapTo<PostBinder>() : PostBinder.EmptyInstance(); ManageViewModel model = new ManageViewModel(); model.Post = post; model.Categories = categories; return this.View(model); }