public async Task <JsonNetResult> Add(AddYouTubeVideoViewModel model)
        {
            // TODO: Add validation
            if (ModelState.IsValid == false)
            {
                return(JsonFailure());
            }

            // Assign a Guid to the video and save
            var videoId = Guid.NewGuid();
            var tags    = model.Tags == null
                           ? new HashSet <string>()
                           : new HashSet <string>(model.Tags.Select(t => t.Trim()));

            await _videoCatalog.SubmitYouTubeVideo(new SubmitYouTubeVideo
            {
                VideoId        = videoId,
                UserId         = User.GetCurrentUserId().Value,
                Name           = model.Name,
                Description    = model.Description,
                Tags           = tags,
                YouTubeVideoId = model.YouTubeVideoId
            });

            // Indicate success
            return(JsonSuccess(new YouTubeVideoAddedViewModel
            {
                ViewVideoUrl = Url.Action("View", "Videos", new { videoId })
            }));
        }
        public async Task Handle(AddSampleYouTubeVideos busCommand)
        {
            // Get some sample users to be the authors for the videos we're going to add
            List <Guid> userIds = await _sampleDataRetriever.GetRandomSampleUserIds(busCommand.NumberOfVideos).ConfigureAwait(false);

            if (userIds.Count == 0)
            {
                Logger.Warn("No sample users available.  Cannot add sample YouTube videos.");
                return;
            }

            // Get some unused sample videos
            List <YouTubeVideo> sampleVideos = await _youTubeManager.GetUnusedVideos(busCommand.NumberOfVideos).ConfigureAwait(false);

            // Add them to the site using sample users
            for (int idx = 0; idx < sampleVideos.Count; idx++)
            {
                YouTubeVideo sampleVideo = sampleVideos[idx];
                Guid         userId      = userIds[idx];

                // Submit the video
                await _videoCatalog.SubmitYouTubeVideo(new SubmitYouTubeVideo
                {
                    VideoId        = Guid.NewGuid(),
                    UserId         = userId,
                    YouTubeVideoId = sampleVideo.YouTubeVideoId,
                    Name           = sampleVideo.Name,
                    Description    = sampleVideo.Description,
                    Tags           = sampleVideo.SuggestedTags
                }).ConfigureAwait(false);

                // Mark them as used so we make a best effort not to reuse sample videos and post duplicates
                await _youTubeManager.MarkVideoAsUsed(sampleVideo).ConfigureAwait(false);
            }
        }