private static void CheckJobs()
        {
            var videoEncodingQueueRepository = new VideoEncodingQueueRepository();
            var videoRepository = new VideoRepository();

            var queued = videoEncodingQueueRepository.GetAll();

            var videoService = new VideoService();

            foreach (var queuedVideo in queued)
            {
                string mp4Url, vc1Url, thumbnailUrl;
                if (videoService.GetJobOutput(queuedVideo.MediaServicesJobId, out mp4Url, out vc1Url, out thumbnailUrl) == JobState.Finished)
                {
                    Console.WriteLine("Job finished: " + queuedVideo.MediaServicesJobId);
                    var video = videoRepository.Get(queuedVideo.VideoId);
                    video.UrlMp4 = mp4Url;
                    video.UrlVc1 = vc1Url;
                    video.ThumbnailUrl = thumbnailUrl;
                    videoRepository.Update(video);

                    videoEncodingQueueRepository.Remove(queuedVideo.RowKey);
                }
            }
        }
        public ActionResult Upload(string title, string description, HttpPostedFileBase file)
        {
            if (!IdentityHelper.IsUserRegistered())
                return RedirectToAction("Register");
            try
            {
                if (file.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "-" + Path.GetFileName(file.FileName);
                    var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                    Directory.CreateDirectory(Server.MapPath("~/App_Data/uploads"));
                    file.SaveAs(path);

                    var videoRep = new VideoRepository();
                    var video = new Video("test", "Foo", "Bar", null, null, null, DateTime.Now);
                    videoRep.Add(video);

                    var videoService = new VideoService();
                    var asset = videoService.CreateAssetAndUploadSingleFile(path);
                    var job = videoService.CreateEncodingJob(asset, path);

                    var videoQueueRep = new VideoEncodingQueueRepository();
                    videoQueueRep.Add(new VideoEncodingQueue(video.RowKey, job.Id));

                }
            }
            catch (Exception e)
            {
                // notify
            }

            return RedirectToAction("Index");
        }