Exemplo n.º 1
0
 public PageDesignFolderContent(ContentPosition pos)
     : base(pos)
 {
     this.Parameter.Add("ContentPositionType", pos.Type.ToString());
     var dataRule = pos.DataRule as FolderDataRule;
     if (dataRule != null)
     {
         var dataRuleJson = new
         {
             FolderName = dataRule.FolderName,
             Top = dataRule.Top,
             WhereClauses = dataRule.WhereClauses
         };
         var serializer = new JavaScriptSerializer();
         var dataRuleJsonString = serializer.Serialize(dataRuleJson);
         this.Parameter.Add("DataRule", PageDesignContent.Code(dataRuleJsonString));
     }
 }
Exemplo n.º 2
0
        protected virtual IHtmlString RenderContentPosition(ContentPosition contentPosition)
        {
            var site = this.PageContext.PageRequestContext.Site;
            var repository = site.GetRepository();
            if (repository == null)
            {
                throw new KoobooException("The repository for site is null.");
            }
            var dataRule = contentPosition.DataRule;
            var dataRuleContext = new DataRuleContext(this.PageContext.PageRequestContext.Site,
                this.PageContext.PageRequestContext.Page) { ValueProvider = this.PageContext.PageRequestContext.GetValueProvider() };
            var contentQuery = dataRule.Execute(dataRuleContext);
            string viewPath = "";
            var schema = dataRule.GetSchema(repository);
            Object model = contentQuery;
            switch (contentPosition.Type)
            {
                case ContentPositionType.Detail:
                    viewPath = schema.GetFormTemplate(FormType.Detail);
                    model = contentQuery.FirstOrDefault();
                    break;
                case ContentPositionType.List:
                default:
                    int top = 10;
                    if (int.TryParse(((FolderDataRule)dataRule).Top, out top))
                    {
                        model = contentQuery.Take(top);
                    }

                    viewPath = schema.GetFormTemplate(FormType.List);
                    break;
            }
            return ViewRender.RenderViewInternal(this.Html, viewPath, null, model);
        }
Exemplo n.º 3
0
        protected virtual IHtmlString RenderContentPosition(ContentPosition contentPosition)
        {
            var site = this.PageContext.PageRequestContext.Site;
            var repository = site.GetRepository();
            if (repository == null)
            {
                throw new KoobooException("The repository for site is null.");
            }
            var dataRule = (IContentDataRule)(contentPosition.DataRule);
            var dataRuleContext = new DataRuleContext(this.PageContext.PageRequestContext.Site,
                this.PageContext.PageRequestContext.Page) { ValueProvider = this.PageContext.PageRequestContext.GetValueProvider() };

            string viewPath = "";
            TakeOperation operation;
            var schema = dataRule.GetSchema(repository);
            switch (contentPosition.Type)
            {
                case ContentPositionType.Detail:
                    viewPath = schema.GetFormTemplate(FormType.Detail);
                    operation = TakeOperation.First;
                    break;
                case ContentPositionType.List:
                default:
                    viewPath = schema.GetFormTemplate(FormType.List);
                    operation = TakeOperation.List;
                    break;
            }
            var model = dataRule.Execute(dataRuleContext, operation, 0);
            return ViewRender.RenderViewInternal(this.Html, viewPath, null, model);
        }