Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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())));
        }
Exemplo n.º 3
0
 public ModelResult <Blog> EditBlog(Blog blog, BlogInput blogInput)
 {
     return(editBlog(blog, blogInput, b => b.Apply(blogInput)));
 }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 public BlogPost UpdateBlogPost(BlogInput input)
 {
     // TODO check owner ship
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public BlogPost CreateBlogPost(BlogInput input)
 {
     // TODO check role "blogger"
     throw new NotImplementedException();
 }