Inheritance: Entity
        public string GetLessonDownloadLink(Lesson lesson)
        {
            var postdata = string.Format(@"{{a:""{0}"", m:""{1}"", course:""{2}"", cn:{3}, mt:""mp4"", q:""1024x768"", cap:false, lc:""en""}}",
                lesson.Author, lesson.Module.Name, lesson.Module.Course.Name, lesson.Number);

            var tempUri = new Uri(_lessonDownloadUrl);

            var encoding = new ASCIIEncoding();
            var data = encoding.GetBytes(postdata);

            var request = HttpWebRequest.Create(tempUri) as HttpWebRequest;

            request.Method = "POST";
            request.ContentType = "application/json;charset=UTF-8";
            request.ContentLength = data.Length;

            request.CookieContainer = _cookieContainer;

            var newStream = request.GetRequestStream();
            newStream.Write(data, 0, data.Length);
            newStream.Close();

            var responseHtml = request.GetResponse();

            var r = new StreamReader(responseHtml.GetResponseStream());
            return r.ReadToEnd();
        }
 private void DownloadLesson(Lesson lesson, string downloadFolder)
 {
     var lessonDownloadLink = _webScraper.GetLessonDownloadLink(lesson);
     var lessonFullFilname = GetLessonFilenameForDownload(lesson, downloadFolder);
     CreateDirectoryIfNotExists(lessonFullFilname);
     new WebClient().DownloadFile(lessonDownloadLink,lessonFullFilname);
 }
 private string GetLessonFilenameForDownload(Lesson lesson, string downloadFolder)
 {
     return string.Format(@"{0}\{1}\{2}\{3}.wmv",
                          downloadFolder,
                          lesson.Module.Course,
                          lesson.Module,
                          lesson);
 }