public Video Publish(int id)
        {
            var video = this.context.Videos.FirstOrDefault(v => v.Id == id);

            if (video == null)
            {
                return null;
            }

            var mediaContext = new CloudMediaContext(
                                             CloudConfigurationManager.GetSetting("MediaServicesAccountName"),
                                             CloudConfigurationManager.GetSetting("MediaServicesAccountKey"));

            string encodedVideoUrl, thumbnailUrl;
            if (mediaContext.PublishJobAsset(video.JobId, out encodedVideoUrl, out thumbnailUrl))
            {
                video.EncodedVideoUrl = encodedVideoUrl;
                video.ThumbnailUrl = thumbnailUrl;
                video.JobId = null;

                this.context.SaveChanges();
            }

            return video;
        }