/// <summary> /// Initializes an instance of <see cref="CafeCardWidgetViewComponent"/> class. /// </summary> public CafeCardWidgetViewComponent( IPageAttachmentUrlRetriever attachmentUrlRetriever, CafeRepository repository) { this.attachmentUrlRetriever = attachmentUrlRetriever; this.repository = repository; }
public void SetUp() { Fake().DocumentType <Article>(Article.CLASS_NAME); page = new Article { DocumentName = "Name" }; var dataContext = Substitute.For <IPageDataContext <TreeNode> >(); dataContext.Page.Returns(page); pageDataContextRetriever.Retrieve <TreeNode>().Returns(dataContext); Fake <SiteInfo, SiteInfoProvider>().WithData( new SiteInfo { SiteID = SITE_ID, SiteName = "Site", SitePresentationURL = "https://presentation.com" }); Fake <AttachmentInfo, AttachmentInfoProvider>().WithData( new AttachmentInfo { AttachmentGUID = attachmentGuid, AttachmentDocumentID = page.DocumentID, AttachmentSiteID = SITE_ID }); attachmentUrlRetriever = Service.Resolve <IPageAttachmentUrlRetriever>(); controller = new ImageWidgetController(pageDataContextRetriever, outputCacheDependencies, propertiesRetriever, attachmentUrlRetriever); controller.ControllerContext = ControllerContextMock.GetControllerContext(controller); }
public void SetUp() { var siteService = Substitute.For <ISiteService>(); var site = Substitute.For <ISiteInfo>(); site.SiteName = "site"; siteService.CurrentSite.Returns(site); Service.Use <ISiteService>(siteService); EnsureServiceContainer(); Fake().DocumentType <Article>(Article.CLASS_NAME); article = TreeNode.New <Article>() .With(a => a.Fields.Title = ARTICLE_TITLE) .With(a => a.SetValue("DocumentID", DOCUMENT_ID)); dependencies = Substitute.For <IOutputCacheDependencies>(); dataContextRetriever = Substitute.For <IPageDataContextRetriever>(); var section = Substitute.For <TreeNode>(); section.NodeAliasPath.Returns("/section"); var dataContext = Substitute.For <IPageDataContext <TreeNode> >(); dataContext.Page.Returns(section); dataContextRetriever.Retrieve <TreeNode>().Returns(dataContext); articleRepository = Substitute.For <IArticleRepository>(); pageUrlRetriever = Substitute.For <IPageUrlRetriever>(); attachmentUrlRetriever = Substitute.For <IPageAttachmentUrlRetriever>(); }
public AttachmentSelectorExample(IComponentPropertiesRetriever propertiesRetriever, ISiteService siteService, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.propertiesRetriever = propertiesRetriever; this.siteService = siteService; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public HomeController(IPageDataContextRetriever pageDataContextRetriever, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.pageDataContextRetriever = pageDataContextRetriever; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public IActionResult Index([FromServices] IPageDataContextRetriever dataContextRetriever, [FromServices] IPageUrlRetriever pageUrlRetriever, [FromServices] IPageAttachmentUrlRetriever attachmentUrlRetriever) { var section = dataContextRetriever.Retrieve <TreeNode>().Page; var articles = articleRepository.GetArticles(section.NodeAliasPath); return(View(articles.Select(article => ArticleViewModel.GetViewModel(article, pageUrlRetriever, attachmentUrlRetriever)))); }
public static SocialLinkViewModel GetViewModel(SocialLink link, IPageAttachmentUrlRetriever attachmentUrlRetriever) { return(new SocialLinkViewModel { Url = link.Fields.Url, Title = link.Fields.Title, IconPath = attachmentUrlRetriever.Retrieve(link.Fields.Icon).RelativePath }); }
public AboutController(IPageDataContextRetriever dataRetriever, IPageAttachmentUrlRetriever pageAttachmentUrlRetriever, AboutUsRepository aboutUsRepository, ReferenceRepository referenceRepository) { this.dataRetriever = dataRetriever; this.pageAttachmentUrlRetriever = pageAttachmentUrlRetriever; this.aboutUsRepository = aboutUsRepository; this.referenceRepository = referenceRepository; }
public SelectorsWidgetViewComponent(IPageAttachmentUrlRetriever attachmentUrlRetriever, IMediaFileInfoProvider mediaFileInfoProvider, IMediaFileUrlRetriever mediaFileUrlRetriever, ISiteService siteService) { this.attachmentUrlRetriever = attachmentUrlRetriever; this.mediaFileInfoProvider = mediaFileInfoProvider; this.mediaFileUrlRetriever = mediaFileUrlRetriever; this.siteService = siteService; }
public CompanyController(ISocialLinkRepository socialLinkRepository, IContactRepository contactRepository, ICountryRepository countryRepository, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.countryRepository = countryRepository; this.socialLinkRepository = socialLinkRepository; this.contactRepository = contactRepository; this.attachmentUrlRetriever = attachmentUrlRetriever; }
/// <summary> /// Initializes an instance of <see cref="CafeCardWidgetController"/> class. /// </summary> /// <param name="repository">Repository for retrieving cafes.</param> /// <param name="outputCacheDependencies">Output cache dependency handling.</param> public CafeCardWidgetController(ICafeRepository repository, IOutputCacheDependencies outputCacheDependencies, IComponentPropertiesRetriever componentPropertiesRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.repository = repository; this.outputCacheDependencies = outputCacheDependencies; this.componentPropertiesRetriever = componentPropertiesRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
/// <summary> /// Gets ViewModel for <paramref name="cafe"/>. /// </summary> /// <param name="cafe">Cafe.</param> /// <param name="attachmentUrlRetriever">Attachment URL retriever.</param> /// <returns>Hydrated view model.</returns> public static CafeCardViewModel GetViewModel(Cafe cafe, IPageAttachmentUrlRetriever attachmentUrlRetriever) { return(cafe == null ? new CafeCardViewModel() : new CafeCardViewModel { Name = cafe.Fields.Name, PhotoPath = cafe.Fields.Photo == null ? null : attachmentUrlRetriever.Retrieve(cafe.Fields.Photo).RelativePath }); }
public ArticleWithSidebarPageTemplateController( IPageDataContextRetriever pageDataContextRetriver, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever, IPageTemplatePropertiesRetriever pageTemplatePropertiesRetriever) { this.pageDataContextRetriver = pageDataContextRetriver; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; this.pageTemplatePropertiesRetriever = pageTemplatePropertiesRetriever; }
/// <summary> /// Creates an instance of <see cref="ImageWidgetController"/> class. /// </summary> /// <param name="pageDataContextRetriever">Retriever for page data context.</param> /// <param name="outputCacheDependencies">Output cache dependencies.</param> /// <param name="propertiesRetriever">Retriever for widget properties.</param> public ImageWidgetController( IPageDataContextRetriever pageDataContextRetriever, IOutputCacheDependencies outputCacheDependencies, IComponentPropertiesRetriever propertiesRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.pageDataContextRetriever = pageDataContextRetriever; this.outputCacheDependencies = outputCacheDependencies; this.propertiesRetriever = propertiesRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public ArticlesController(IPageDataContextRetriever dataContextRetriever, IArticleRepository articleRepository, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever, IOutputCacheDependencies outputCacheDependencies) { this.dataContextRetriever = dataContextRetriever; this.articleRepository = articleRepository; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; this.outputCacheDependencies = outputCacheDependencies; }
public CafesController(IPageDataContextRetriever dataContextRetriever, ICafeRepository cafeRespository, ICountryRepository countryRepository, IOutputCacheDependencies outputCacheDependencies, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.dataContextRetriever = dataContextRetriever; this.cafeRespository = cafeRespository; this.countryRepository = countryRepository; this.outputCacheDependencies = outputCacheDependencies; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public SelectorsWidgetController(IPageAttachmentUrlRetriever attachmentUrlRetriever, IComponentPropertiesRetriever propertiesRetriever, IMediaFileInfoProvider mediaFileInfoProvider, IMediaFileUrlRetriever mediaFileUrlRetriever, ISiteService siteService) { this.attachmentUrlRetriever = attachmentUrlRetriever; this.propertiesRetriever = propertiesRetriever; this.mediaFileInfoProvider = mediaFileInfoProvider; this.mediaFileUrlRetriever = mediaFileUrlRetriever; this.siteService = siteService; }
public CafesController(IPageDataContextRetriever dataContextRetriever, CafeRepository cafeRepository, CountryRepository countryRepository, IStringLocalizer <SharedResources> localizer, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.dataContextRetriever = dataContextRetriever; this.cafeRepository = cafeRepository; this.countryRepository = countryRepository; this.localizer = localizer; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public KenticoMediaRepository(ISiteService SiteRepo, IPageAttachmentUrlRetriever pageAttachmentUrlRetriever, IAttachmentInfoProvider attachmentInfoProvider, IMediaFileInfoProvider mediaFileInfoProvider, IEventLogService eventLogService) { _SiteRepo = SiteRepo; _pageAttachmentUrlRetriever = pageAttachmentUrlRetriever; _attachmentInfoProvider = attachmentInfoProvider; _mediaFileInfoProvider = mediaFileInfoProvider; _eventLogService = eventLogService; }
public HomeController(IPageDataContextRetriever pageDataContextRetriever, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever, HomeRepository homeSectionRepository, ReferenceRepository referenceRepository) { this.pageDataContextRetriever = pageDataContextRetriever; this.homeSectionRepository = homeSectionRepository; this.referenceRepository = referenceRepository; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public AboutController(IPageDataContextRetriever dataRetriever, IAboutUsRepository aboutUsRepository, IReferenceRepository referenceRepository, IOutputCacheDependencies outputCacheDependencies, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.dataRetriever = dataRetriever; this.aboutUsRepository = aboutUsRepository; this.referenceRepository = referenceRepository; this.outputCacheDependencies = outputCacheDependencies; this.attachmentUrlRetriever = attachmentUrlRetriever; }
/// <summary> /// Initializes an instance of <see cref="ArticlesWidgetController"/> class. /// </summary> /// <param name="repository">Articles repository.</param> /// <param name="outputCacheDependencies">Output cache dependency handling.</param> /// <param name="propertiesRetriever">Retriever for widget properties.</param> /// <param name="pageBuilderDataContextRetriever">Retriever for page builder data context.</param> /// <param name="pageUrlRetriever">Retriever for page URLs.</param> /// <param name="attachmentUrlRetriever">Retriever for page attachment URLs.</param> /// <remarks>Use this constructor for tests to handle dependencies.</remarks> public ArticlesWidgetController(IArticleRepository repository, IOutputCacheDependencies outputCacheDependencies, IComponentPropertiesRetriever propertiesRetriever, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.repository = repository; this.outputCacheDependencies = outputCacheDependencies; this.propertiesRetriever = propertiesRetriever; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public HomeController(IPageDataContextRetriever pageDataContextRetriever, IHomeRepository homeSectionRepository, IReferenceRepository referenceRepository, IOutputCacheDependencies outputCacheDependencies, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.pageDataContextRetriever = pageDataContextRetriever; this.homeSectionRepository = homeSectionRepository; this.referenceRepository = referenceRepository; this.pageUrlRetriever = pageUrlRetriever; this.outputCacheDependencies = outputCacheDependencies; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public static ReferenceViewModel GetViewModel(Reference reference, IPageAttachmentUrlRetriever attachmentUrlRetriever) { if (reference == null) { return(null); } return(new ReferenceViewModel { Name = reference.ReferenceName, Description = reference.ReferenceDescription, Text = reference.ReferenceText, ImagePath = attachmentUrlRetriever.Retrieve(reference.Fields.Image).RelativePath }); }
public RepositoryServices( ISiteService siteService, ISiteContextService siteContextService, IPageRetriever pageRetriever, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever pageAttachmentUrlRetriever, ISiteCultureRepository siteCultureRepository, IProgressiveCache progressiveCache) { SiteService = siteService ?? throw new ArgumentNullException(nameof(siteService)); SiteContextService = siteContextService ?? throw new ArgumentNullException(nameof(siteContextService)); PageRetriever = pageRetriever ?? throw new ArgumentNullException(nameof(pageRetriever)); PageUrlRetriever = pageUrlRetriever ?? throw new ArgumentNullException(nameof(pageUrlRetriever)); PageAttachmentUrlRetriever = pageAttachmentUrlRetriever ?? throw new ArgumentNullException(nameof(pageAttachmentUrlRetriever)); SiteCultureRepository = siteCultureRepository ?? throw new ArgumentNullException(nameof(siteCultureRepository)); ProgressiveCache = progressiveCache ?? throw new ArgumentNullException(nameof(progressiveCache)); }
public static RelatedArticleViewModel GetViewModel(Article article, bool handleArticlePosition, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { return(new RelatedArticleViewModel { Summary = article.Fields.Summary, TeaserPath = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser).WithSizeConstraint(SizeConstraint.Height(301)).RelativePath, Title = article.Fields.Title, PublicationDate = article.PublicationDate, HandleArticlePosition = handleArticlePosition, Url = pageUrlRetriever.Retrieve(article).RelativePath }); }
public static HomeSectionViewModel GetViewModel(HomeSection homeSection, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { var link = homeSection?.Fields.Link.FirstOrDefault(); return(homeSection == null ? null : new HomeSectionViewModel { Heading = homeSection.Fields.Heading, Text = homeSection.Fields.Text, MoreButtonText = homeSection.Fields.LinkText, MoreButtonUrl = link != null?pageUrlRetriever.Retrieve(link).RelativePath : string.Empty }); }
/// <summary> /// Creates an instance of <see cref="ArticlesWidgetController"/> class. /// </summary> /// <param name="repository">Article repository.</param> /// <param name="pageUrlRetriever">Retriever for page URLs.</param> public ArticlesWidgetViewComponent(ArticleRepository repository, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.repository = repository; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public ArticlePageTemplateController(IPageDataContextRetriever pageDataContextRetriver, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { this.pageDataContextRetriver = pageDataContextRetriver; this.pageUrlRetriever = pageUrlRetriever; this.attachmentUrlRetriever = attachmentUrlRetriever; }
public static ArticleWithSideBarViewModel GetViewModel(Article article, ArticleWithSideBarProperties templateProperties, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever) { return(new ArticleWithSideBarViewModel { TeaserPath = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser).RelativePath, PublicationDate = article.PublicationDate, RelatedArticles = article.Fields.RelatedArticles.OfType <Article>().Select(relatedArticle => RelatedArticleViewModel.GetViewModel(relatedArticle, false, pageUrlRetriever, attachmentUrlRetriever)), Text = article.Fields.Text, Title = article.Fields.Title, SidebarLocation = (ArticleSidebarLocationEnum)Enum.Parse(typeof(ArticleSidebarLocationEnum), templateProperties.SidebarLocation, true), ArticleWidth = templateProperties.ArticleWidth, }); }