示例#1
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            OxiteViewModel model = filterContext.Controller.ViewData.Model as OxiteViewModel;

            if (model != null)
            {
                List <ContentItem> contentItems = new List <ContentItem>(50);
                Page   page     = null;
                string pagePath = filterContext.RouteData.Values.ContainsKey("pagePath") ? filterContext.RouteData.Values["pagePath"] as string : null;

                if (!string.IsNullOrEmpty(pagePath))
                {
                    page = pageService.GetPage(new PageAddress(getRealPagePath(filterContext, pagePath)));
                }

                if (page != null)
                {
                    //TODO: (erikpo) Could the following be done just in LINQ?

                    contentItems.AddRange(pageService.GetContentItems(page));

                    foreach (ContentItem contentItem in contentItemService.GetContentItems())
                    {
                        if (!contentItems.Any(ci => string.Compare(ci.Name, contentItem.Name, true) == 0))
                        {
                            contentItems.Add(contentItem);
                        }
                    }
                }
                else
                {
                    contentItems.AddRange(contentItemService.GetContentItems());
                }

                model.AddModelItem(new ContentItemViewModel(contentItems));
            }
        }
示例#2
0
        public OxiteViewModelItems <ContentItemInput> GlobalEdit(IEnumerable <ContentItemInput> contentInput)
        {
            //TODO: (erikpo) Check permissions

            return(new OxiteViewModelItems <ContentItemInput>(contentItemService.GetContentItems().Select(ci => new ContentItemInput(ci.Name, ci.DisplayName, ci.Body, ci.Published))));
        }