public async Task<Video> CreateVideoAsync(string title, string description, string name, string type, Stream dataStream)
        {
            // Create an instance of the CloudMediaContext
            var mediaContext = new CloudMediaContext(
                                             CloudConfigurationManager.GetSetting("MediaServicesAccountName"),
                                             CloudConfigurationManager.GetSetting("MediaServicesAccountKey"));

            // Create the Media Services asset from the uploaded video
            var asset = mediaContext.CreateAssetFromStream(name, title, type, dataStream);

            // Get the Media Services asset URL
            var videoUrl = mediaContext.GetAssetVideoUrl(asset);

            // Launch the smooth streaming encoding job and store its ID
            var jobId = mediaContext.ConvertAssetToSmoothStreaming(asset, true);

            var video = new Video
                {
                    Title = title,
                    Description = description,
                    SourceVideoUrl = videoUrl,
                    JobId = jobId
                };

            this.context.Videos.Add(video);
            await this.context.SaveChangesAsync();

            return video;
        }