Пример #1
0
        public async Task <IHtmlContent> InvokeAsync()
        {
            var viewModel = await DeliveryObservable
                            .GetItemObservable <Site>("site")
                            .Select(s => s.Sidebar.Cast <SidebarItem>().Select(i => new SidebarItemViewModel(i)));

            return(RenderReactComponent(new { model = viewModel }, containerId: "sidebar"));
        }
Пример #2
0
        public async Task <IHtmlContent> InvokeAsync(AnnouncementLocationEnum announcementLocation)
        {
            var viewModel = await DeliveryObservable
                            .GetItemObservable <Site>("site")
                            .Select(s => s.Announcements
                                    .Where(a => a.System.Codename != CookieConsentComponent.COOKIE_CONSENT_ANNOUNCEMENT_CODENAME &&
                                           a.Location.FirstOrDefault().ToEnum <AnnouncementLocationEnum>() == announcementLocation)
                                    .Select(a => new AnnouncementViewModel(a)));

            return(RenderReactComponent(new { model = viewModel }));
        }
Пример #3
0
        public async Task <IActionResult> Index([FromServices] IReviewService reviewService)
        {
            var reviews = await reviewService.GetReviews().ToListAsync();

            ViewBag.Reviews = reviews;

            return(await DeliveryObservable
                   .GetItemObservable <Site>("site")
                   .Select(s => new SiteViewModel(s))
                   .ToActionResult(View));
        }
Пример #4
0
        public async Task <IHtmlContent> InvokeAsync()
        {
            var    consentFeature = HttpContext.Features.Get <ITrackingConsentFeature>();
            var    showBanner     = !consentFeature?.CanTrack ?? false;
            string cookieString   = null;

            if (showBanner)
            {
                cookieString = consentFeature?.CreateConsentCookie();
            }

            var viewModel = await DeliveryObservable
                            .GetItemObservable <Site>("site")
                            .Select(s => s.Announcements
                                    .Where(a => a.System.Codename == COOKIE_CONSENT_ANNOUNCEMENT_CODENAME)
                                    .Select(a => new CookieConsentViewModel(a, cookieString))
                                    .FirstOrDefault());

            return(RenderReactComponent(new { model = viewModel }));
        }