Exemplo n.º 1
0
            public List <BannerBlockItemViewModel> Resolve(BlockModel block, BannersBlockViewModel bannersViewModel, List <BannerBlockItemViewModel> destMember, ResolutionContext context)
            {
                var result        = new List <BannerBlockItemViewModel>();
                var blockTemplate = _fieldTemplateService.Get <FieldTemplateBase>(block.FieldTemplateSystemId);

                if (blockTemplate.FieldGroups.Any(x => x.Id == "Banners"))
                {
                    var banners = block.GetValue <IList <MultiFieldItem> >(BlockFieldNameConstants.Banners);
                    if (banners != null)
                    {
                        result.AddRange(banners.Select(c => c.MapTo <BannerBlockItemViewModel>()));
                    }
                }
                else if (blockTemplate.FieldGroups.Any(x => x.Id == "Banner"))
                {
                    var linkToPage = block.GetValue <PointerPageItem>(BlockFieldNameConstants.Link)?.MapTo <LinkModel>();
                    var banner     = new BannerBlockItemViewModel()
                    {
                        ActionText = block.GetValue <string>(BlockFieldNameConstants.BlockText),
                        Image      = block.GetValue <Guid>(BlockFieldNameConstants.BlockImagePointer).MapTo <ImageModel>(),
                        LinkUrl    = !string.IsNullOrEmpty(linkToPage?.Href) ? linkToPage.Href : ""
                    };
                    result.Add(banner);
                }

                return(result);
            }
Exemplo n.º 2
0
            public List <BannerBlockItemViewModel> Resolve(BlockModel block, BannersBlockViewModel bannersViewModel, List <BannerBlockItemViewModel> destMember, ResolutionContext context)
            {
                var result        = new List <BannerBlockItemViewModel>();
                var blockTemplate = _fieldTemplateService.Get <FieldTemplateBase>(block.FieldTemplateSystemId);

                if (blockTemplate.FieldGroups.Any(x => x.Id == "Banners"))
                {
                    var banners = block.GetValue <IList <MultiFieldItem> >(BlockFieldNameConstants.Banners);
                    if (banners != null)
                    {
                        result.AddRange(banners.Select(c => c.MapTo <BannerBlockItemViewModel>()));
                    }
                }
                else if (blockTemplate.FieldGroups.Any(x => x.Id == "Banner"))
                {
                    var image  = block.GetValue <Guid>(BlockFieldNameConstants.BlockImagePointer).MapTo <ImageModel>();
                    var banner = new BannerBlockItemViewModel()
                    {
                        LinkText   = block.GetValue <string>(BlockFieldNameConstants.LinkText),
                        ActionText = block.GetValue <string>(BlockFieldNameConstants.ActionText),
                        Image      = image,
                        ImageUrl   = image.GetUrlToImage(new System.Drawing.Size(786, -1), new System.Drawing.Size(1314, -1)).Url,
                        LinkUrl    = GetBannerUrl(block)
                    };
                    result.Add(banner);
                }

                return(result);
            }
Exemplo n.º 3
0
            public List <BannerBlockItemViewModel> Resolve(BlockModel block, SliderBlockViewModel viewModel, List <BannerBlockItemViewModel> destMember, ResolutionContext context)
            {
                var result        = new List <BannerBlockItemViewModel>();
                var blockTemplate = _fieldTemplateService.Get <FieldTemplateBase>(block.FieldTemplateSystemId);

                if (blockTemplate.FieldGroups.Any(x => x.Id == "Slides"))
                {
                    var blockItems = block.GetValue <IList <MultiFieldItem> >(BlockFieldNameConstants.Slider);
                    if (blockItems != null)
                    {
                        result.AddRange(blockItems.Select(c => c.MapTo <BannerBlockItemViewModel>()));
                    }
                }

                return(result);
            }
        protected object ResolvePages(BlockModel brandBlock, BrandsBlockViewModel model)
        {
            var rs         = new List <LinkModel>();
            var brandPages = brandBlock.GetValue <IList <PointerItem> >(BlockFieldNameConstants.BrandsLinkList)?.OfType <PointerPageItem>().ToList() ?? new List <PointerPageItem>();

            foreach (var brandPage in brandPages)
            {
                var page = brandPage.MapTo <LinkModel>();

                if (page != null)
                {
                    var fileSystemId = brandPage.EntitySystemId.MapTo <PageModel>()?.GetValue <Guid>(PageFieldNameConstants.Image);
                    if (fileSystemId != null && fileSystemId != Guid.Empty)
                    {
                        page.Image = fileSystemId.MapTo <ImageModel>();
                    }

                    rs.Add(page);
                }
            }

            return(rs);
        }