コード例 #1
0
 private OfficeViewModel ToViewModel(DynamicContent office) =>
 new OfficeViewModel
 {
     Id      = office.Id,
     Title   = office.GetString("Title").Value,
     Info    = office.GetString("Info").Value,
     Picture = this.GetImageViewModel(office.GetRelatedItems <Image>("Picture").ToList())
 };
コード例 #2
0
ファイル: AuthorsService.cs プロジェクト: zzareva/mvc-samples
        public AuthorViewModel GetAuthor(DynamicContent item)
        {
            AuthorViewModel author = new AuthorViewModel();

            author.Name     = item.GetString("Name");
            author.JobTitle = item.GetString("JobTitle");
            author.Bio      = item.GetString("Bio");

            return(author);
        }
コード例 #3
0
 /// <summary>
 /// Gets the author view model.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <param name="currentNewsItem">The current news item.</param>
 /// <returns>Author View Moddel</returns>
 public static AuthorViewModel GetAuthorViewModel(DynamicContent obj)
 {
     return(new AuthorViewModel(obj)
     {
         Name = obj.GetString("Name"),
         JobTitle = obj.GetString("JobTitle"),
         Bio = obj.GetString("Bio"),
         Avatar = WidgetExtensions.GetRelatedMediaUrl(obj, "Avatar")
     });
 }
コード例 #4
0
        private CarViewModel GetViewModel(DynamicContent dContent)
        {
            CarViewModel viewModel = new CarViewModel();

            viewModel.Id = dContent.Id;
            viewModel.Title = dContent.GetString("Title").Value;
            viewModel.Info = dContent.GetString("CarInfo").Value;

            if (dContent.GetRelatedItemsCountByField("CarImages") > 0)
            {
                viewModel.Image = dContent.GetRelatedItems<Image>("CarImages").FirstOrDefault();
            }

            return viewModel;
        }
コード例 #5
0
ファイル: House.cs プロジェクト: avisra/SitefinityCacheSample
        public House(DynamicContent house)
        {
            this.Id      = house.OriginalContentId;
            this.Title   = house.GetString("Title");
            this.LogoUrl = house.GetRelatedItems <Image>("Logo")?.FirstOrDefault()?.MediaUrl;

            this.CacheDate = DateTime.Now;
        }
コード例 #6
0
ファイル: IssueViewModel.cs プロジェクト: zzareva/mvc-samples
        /// <summary>
        /// Gets the issue view model.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public static IssueViewModel GetIssue(DynamicContent item)
        {
            IssueViewModel issue = new IssueViewModel();

            issue.Title           = item.GetString("Title");
            issue.Id              = item.Id;
            issue.UrlName         = item.ItemDefaultUrl;
            issue.Description     = item.GetString("Description");
            issue.Number          = item.GetString("IssueNumber");
            issue.Cover           = ImagesHelper.GetRelatedImage(item, "IssueCover");
            issue.ProviderName    = item.ProviderName;
            issue.PrintedVersion  = DocumentsHelper.GetRelatedDocument(item, "IssueDocument");
            issue.Articles        = item.GetRelatedItems <NewsItem>("Articles");
            issue.FeaturedArticle = item.GetRelatedItems <NewsItem>("FeaturedArticle");

            return(issue);
        }
コード例 #7
0
 /// <summary>
 /// Gets the author view model.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <param name="currentNewsItem">The current news item.</param>
 /// <returns>Author View Moddel</returns>
 public static AuthorViewModel GetAuthorViewModel(DynamicContent obj, NewsItem currentNewsItem = null)
 {
     return(new AuthorViewModel
     {
         Id = obj.Id,
         Author = obj,
         ItemDefaultUrl = obj.ItemDefaultUrl,
         Name = obj.GetString("Name"),
         JobTitle = obj.GetString("JobTitle"),
         Bio = obj.GetString("Bio"),
         Avatar = new ImageViewModel()
         {
             ImageUrl = UrlHelper.GetRelatedMediaUrl(obj, "Avatar")
         },
         ProviderName = obj.ProviderName,
         RelatedArticles = AuthorViewModel.GetRelatedArticles(obj),
         DetailedArticle = (currentNewsItem != null) ? currentNewsItem : null
     });
 }
コード例 #8
0
        private void ProductsList_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
        {
            if (e.Item is RadListViewDataItem)
            {
                HtmlControl    heading3     = e.Item.FindControl("ProductTitle") as HtmlControl;
                DynamicContent productItem  = ((RadListViewDataItem)e.Item).DataItem as DynamicContent;
                string         productTitle = String.Empty;

                if (productItem != null)
                {
                    productTitle = productItem.GetString("Title");
                }

                if (heading3 != null)
                {
                    if (productTitle.StartsWith("EU"))
                    {
                        HtmlGenericControl span = new HtmlGenericControl("span");
                        span.Attributes.Add("class", productNameSpanClass);
                        string  firstPart  = productTitle.Substring(0, 2);
                        string  secondPart = productTitle.Substring(2);
                        Literal literalEU  = new Literal();
                        literalEU.Text = firstPart;
                        heading3.Controls.Add(literalEU);

                        span.InnerText = secondPart;
                        heading3.Controls.Add(span);
                    }
                    else
                    {
                        Literal productTitleLtl = new Literal();
                        productTitleLtl.Text = productTitle;
                        heading3.Controls.Add(productTitleLtl);
                    }
                }

                //Add NavigateUrl to Policy Coverage link
                HyperLink policyCoverageLink     = e.Item.FindControl("PolicyCoverageLink") as HyperLink;
                PageNode  policyCoveragePageNode = productItem.GetValue("PolicyCoverageLandingPage") as PageNode;

                if (policyCoverageLink != null && policyCoveragePageNode != null)
                {
                    policyCoverageLink.NavigateUrl = PagesUtilities.GetPageUrlByPageNode(policyCoveragePageNode);
                }

                //Add NavigateUrl to Read More link
                HyperLink readMoreLink     = e.Item.FindControl("ReadMoreLink") as HyperLink;
                PageNode  readMorePageNode = productItem.GetValue("ReadMoreLandingPage") as PageNode;

                if (readMoreLink != null && readMorePageNode != null)
                {
                    readMoreLink.NavigateUrl = PagesUtilities.GetPageUrlByPageNode(readMorePageNode);
                }
            }
        }
コード例 #9
0
        public ActionResult Detail(string urlName)
        {
            var projectModel = new ProjectsModel();

            DynamicContent project = RetrieveCollectionOfProjects().Where(p => p.UrlName == urlName).SingleOrDefault();

            projectModel.Title = project.GetString("Title");

            projectModel.Bugs = RetrieveCollectionOfBugs()
                                .Where(b => b.SystemParentId == DynamicModuleManager.Lifecycle.GetMaster(project).Id);

            return(View("Detail", projectModel));
        }
コード例 #10
0
 /// <summary>
 /// Gets the author view model.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <param name="currentNewsItem">The current news item.</param>
 /// <returns>Author View Moddel</returns>
 public static AuthorViewModel GetAuthorViewModel(DynamicContent obj, NewsItem currentNewsItem = null)
 {
     return new AuthorViewModel
     {
         Id = obj.Id,
         Author = obj,
         ItemDefaultUrl = obj.ItemDefaultUrl,
         Name = obj.GetString("Name"),
         JobTitle = obj.GetString("JobTitle"),
         Bio = obj.GetString("Bio"),
         Avatar = new ImageViewModel() { ImageUrl = UrlHelper.GetRelatedMediaUrl(obj, "Avatar") },
         ProviderName = obj.ProviderName,
         RelatedArticles = AuthorViewModel.GetRelatedArticles(obj),
         DetailedArticle = (currentNewsItem != null) ? currentNewsItem : null
     };
 }
コード例 #11
0
        /// <summary>
        /// Gets the issue view model.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public static IssueViewModel GetIssue(DynamicContent item)
        {
            IssueViewModel issue = new IssueViewModel();

            issue.Title = item.GetString("Title");
            issue.Id = item.Id;
            issue.UrlName = item.ItemDefaultUrl;
            issue.Description = item.GetString("Description");
            issue.Number = item.GetString("IssueNumber");
            issue.Cover = ImagesHelper.GetRelatedImage(item, "IssueCover");
            issue.ProviderName = item.ProviderName;
            issue.PrintedVersion = DocumentsHelper.GetRelatedDocument(item, "IssueDocument");
            issue.Articles = item.GetRelatedItems<NewsItem>("Articles");
            issue.FeaturedArticle = item.GetRelatedItems<NewsItem>("FeaturedArticle");

            return issue;
        }