예제 #1
0
            public void GetVideoEmbedUrl_ProvidedVariousVideoKinds_GetCorrectVideoFormat(VideoKindEnum kind, string embedUrlPrefix)
            {
                var model = new VideoWidgetViewModel("foo", "123456", kind);
                string actualEmbedUrl = VideoHelper.GetVideoEmbedUrl(model);

                Assert.That(actualEmbedUrl, Does.StartWith(embedUrlPrefix));
            }
예제 #2
0
        public PartialViewResult Sidebars()
        {
            //MVC 5 does not support asynchronous in partial view. Fetch the data synchronously
            ViewBag.ApprovedVideos  = VideoWidgetViewModel.Create(_uow, 1, 10, "approved", string.Empty);
            ViewBag.HasPlayedVideos = VideoWidgetViewModel.Create(_uow, 1, 10, "hasplayed", string.Empty);

            return(PartialView("_Sidebars"));
        }
        // GET: VideoWidget
        public ActionResult Index()
        {
            var properties = GetProperties();
            var viewModel  = new VideoWidgetViewModel
            {
                VideoUrl = properties.VideoUrl,
            };

            return(PartialView("~/Views/Shared/Kentico/Widgets/_VideoWidget.cshtml", viewModel));
        }
예제 #4
0
        public IActionResult DeleteVideoLink(VideoWidgetViewModel model)
        {
            if (model.Id != null)
            {
                _videoService.DeleteModel(model.Id);
                return(Ok());
            }

            return(BadRequest());
        }
예제 #5
0
        public async Task <IViewComponentResult> InvokeAsync(VideoWidgetViewModel model)
        {
            var modelText = JsonConvert.SerializeObject(model, new JsonSerializerSettings {
                Formatting = Formatting.Indented
            });

            ViewData["modelText"] = modelText;

            return(View(model));
        }
예제 #6
0
        public async Task <IViewComponentResult> InvokeAsync(VideoWidgetViewModel model)
        {
            ViewBag.VideoSourceTypes = GetVideoSourceTypesAsSelectList();

            if (isLiveVideoEnabled())
            {
                ViewBag.LiveVideoList = await GetVideoStreamLinksAsSelectListAsync();
            }

            //ViewBag.OnDemandVideoList = await GetFileDocumentsAsSelectListAsync();
            return(View(model));
        }
예제 #7
0
        public IActionResult UpdateVideoLink(VideoWidgetViewModel model)
        {
            if (ModelState.IsValid)
            {
                // If the full URL is entered, then extract just the video id.
                if (model.VideoSourceType == VideoSourceTypes.YouTube)
                {
                    model.YouTubeVideoId = ExtractYouTubeIdFromUrl(model.YouTubeVideoId);
                }

                _videoService.UpdateModel(model);
                return(Ok(model));
            }

            return(BadRequest(ModelState));
        }
예제 #8
0
 public void GetVideoEmbedUrl_VideoIsNotSupported_ThrowsNotSupportedException()
 {
     var model = new VideoWidgetViewModel("foo", "bar", VideoKindEnum.Unknown);
     Assert.Throws<NotSupportedException>(() => VideoHelper.GetVideoEmbedUrl(model));
 }