// GET: Files/Create
        public ActionResult Create(string lessonID)
        {
            TutorialUploadModel model = new TutorialUploadModel();

            model.LessionID = Guid.Parse(lessonID);
            Dictionary <string, string> contentTypesDict = new Dictionary <string, string>();

            contentTypesDict.Add("Video", "Video");
            contentTypesDict.Add("PDF", "PDF File");
            SelectList contentTypeList = new SelectList(contentTypesDict.Select(x => new { Value = x.Key, Text = x.Value }), "Value", "Text");

            ViewBag.ContentTypeList = contentTypeList;
            return(View(model));
        }
        public async Task <ActionResult> Create(TutorialUploadModel file)
        {
            string FileName      = Path.GetFileNameWithoutExtension(file.FileContent.FileName);
            string FileExtension = Path.GetExtension(file.FileContent.FileName);

            FileName = FileName.Trim() + FileExtension;
            byte[] Bytes = new byte[file.FileContent.ContentLength];
            file.FileContent.InputStream.Read(Bytes, 0, Bytes.Length);

            //upload to blob
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=ibmhackathonblobstorage;AccountKey=UXNuGcVonynbneCODLG/DLzXh9qeO2T7Ws3l0Fr4/G7l1wQHXmX71rKyvf/oMJLgHhHSlzI03fHAreitXt9TyA==;EndpointSuffix=core.windows.net");
            CloudBlobClient     cloudBlobClient     = cloudStorageAccount.CreateCloudBlobClient();
            CloudBlobContainer  cloudBlobContainer  = cloudBlobClient.GetContainerReference("tutorialvideos");
            CloudBlockBlob      cloudBlockBlob      = cloudBlobContainer.GetBlockBlobReference(FileName);

            cloudBlockBlob.Properties.ContentType = file.FileContent.ContentType;
            await cloudBlockBlob.UploadFromByteArrayAsync(Bytes, 0, Bytes.Length);

            Models.File _file = new Models.File();
            _file.FileName  = FileName;
            _file.FileType  = file.FileType;
            _file.LessionID = file.LessionID;
            _file.Lesson    = await db.Lessons.FindAsync(file.LessionID);

            _file.UploadDate     = DateTime.Now;
            _file.ContentURL     = cloudBlockBlob.Uri.AbsoluteUri;
            _file.ContentDetails = "";
            _file.FileID         = Guid.NewGuid();
            db.Files.Add(_file);
            await db.SaveChangesAsync();

            if (_file.FileType == "Video")
            {
                MethodHelpers methodHelper = new MethodHelpers();
                methodHelper.TriggerTranscribe(_file.FileID.ToString());
            }
            return(RedirectToAction("Index", "Lessons"));
        }