예제 #1
0
        public virtual object ItemSave(Area areaInput)
        {
            ValidationStateDictionary validationState;

            if (areaInput.ID == Guid.Empty)
            {
                Area area;
                areaService.AddArea(areaInput, out validationState, out area);

                //TODO: (erikpo) Get rid of HasMultipleAreas and make it a calculated field so the following isn't necessary
                Site siteToEdit = siteService.GetSite(site.Name);

                siteToEdit.HasMultipleAreas = true;

                siteService.EditSite(siteToEdit, out validationState);

                if (validationState.IsValid)
                {
                    OxiteApplication.Load(ControllerContext.HttpContext);
                }
            }
            else
            {
                areaService.EditArea(areaInput, out validationState);
            }

            if (!validationState.IsValid)
            {
                ModelState.AddModelErrors(validationState);

                return(ItemEdit(areaInput));
            }

            return(Redirect(Url.Admin()));
        }
예제 #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())));
        }