Ejemplo n.º 1
0
        public ActionResult Index()
        {
            ViewBag.FrontPageBanners   = _settings.FrontPageBanners;
            ViewBag.ContentBannerLeft  = _settings.ContentBannerLeft;
            ViewBag.ContentBannerRight = _settings.ContentBannerRight;

            if (!_userAgentVerifier.IsMobileDevice(Request.UserAgent))
            {
                ViewBag.VideoViewBanner = _settings.VideoViewBanner;
            }

            return(View());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index(string id)
        {
            // Social bots
            if (_userAgentVerifier.IsSocialBot(Request.UserAgent) && ContainsOverrideParams())
            {
                VideoModel videoModel = GetVideoModel(id);
                return(View("OgTags", videoModel));
            }

            // Get video
            Watch project;

            try
            {
                project = await _watchProjectRepository.GetByIdAsync(id, UserId);

                // Post-processing
                if (User.IsInRole(DomainRoles.User))
                {
                    project.IsLiked = await _projectLikesService.IsLikedAsync(id, UserId);

                    project.IsDisliked = await _projectLikesService.IsDislikedAsync(id, UserId);
                }

                // For statistics
                HttpContext.Items.Add("isReady", project.State == WatchState.Ready);
            }
            catch (ForbiddenException)
            {
                // Go home if forbidden
                return(RedirectToAction("Index", "Home"));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
            catch (UnauthorizedException)
            {
                // Go home if unauthorized
                // In case user is unauthorized we should show him 401-error-page.
                // But there isn't one so for now it would be redirect on Home page.
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to retrieve project {0}: {1}", id, e);
                return(HttpNotFound());
            }

            VideoModel model = await GetVideoModel(project, id);

            // Get current user avatar url
            DomainUser user = null;

            try
            {
                user = await _userService.GetAsync(UserId);
            }
            catch (NotFoundException)
            {
            }

            model.UserAvatarUrl = _userAvatarProvider.GetAvatar(user);

            // Show banners for non-mobile devices
            if (!_userAgentVerifier.IsMobileDevice(Request.UserAgent))
            {
                ViewBag.VideoViewBanner = _settings.VideoViewBanner;
            }

            return(View("Index", model));
        }