public ModelResult <Blog> AddBlog(BlogInput blogInput) { ValidationStateDictionary validationState = new ValidationStateDictionary(); validationState.Add(typeof(BlogInput), validator.Validate(blogInput)); if (!validationState.IsValid) { return(new ModelResult <Blog>(validationState)); } Blog blog; using (TransactionScope transaction = new TransactionScope()) { blog = blogInput.ToBlog(context.Site.ID); validateBlog(blog, validationState); if (!validationState.IsValid) { return(new ModelResult <Blog>(validationState)); } blog = repository.Save(blog); invalidateCachedBlogDependencies(blog); transaction.Complete(); } pluginEngine.ExecuteAll("BlogAdded", new { context, blog = new BlogReadOnly(blog) }); return(new ModelResult <Blog>(blog, validationState)); }
public object ItemSave(Blog blog, BlogInput blogInput) { //TODO: (erikpo) Check permissions ValidationStateDictionary validationState; if (blog == null) { ModelResult <Blog> results = blogService.AddBlog(blogInput); validationState = results.ValidationState; if (results.IsValid) { ////TODO: (erikpo) Get rid of HasMultipleBlogs and make it a calculated field so the following isn't necessary //Site siteToEdit = siteService.GetSite(site.Name); //siteToEdit.HasMultipleBlogs = true; //siteService.EditSite(siteToEdit, out validationState); if (validationState.IsValid) { OxiteApplication.Load(ControllerContext.HttpContext); } } } else { ModelResult <Blog> results = blogService.EditBlog(blog, blogInput); validationState = results.ValidationState; } if (!validationState.IsValid) { ModelState.AddModelErrors(validationState); return(ItemEdit(blog)); } return(Redirect(Url.AppPath(Url.Admin()))); }
public ModelResult <Blog> EditBlog(Blog blog, BlogInput blogInput) { return(editBlog(blog, blogInput, b => b.Apply(blogInput))); }
public static Blog Apply(this Blog blog, BlogInput input) { return(new Blog(blog.Site.ID, input.CommentingDisabled, blog.Created, input.Description, input.DisplayName, blog.ID, blog.Modified, input.Name)); }
public BlogPost UpdateBlogPost(BlogInput input) { // TODO check owner ship throw new NotImplementedException(); }
public BlogPost CreateBlogPost(BlogInput input) { // TODO check role "blogger" throw new NotImplementedException(); }