public ActionResult AddLesson( string Name, string Description, string Links, int id )
        {
            if( Name == null || Name == "" ) {
                Name = "Урок";
            }
            CourseInstance courseInstance = db.CourseInstance.Where( p => id == p.ID ).FirstOrDefault();
            Person author = db.Users.Where( p => User.Identity.Name == p.UserName ).FirstOrDefault();
            if( !courseInstance.BaseCourse.Teachers.Contains( author ) ) {
                ViewBag.Message = "У вас нет прав на редактирование этих материалов";
                return View( "Error" );
            }
            var lesson = new Lesson() { Name = Name, Description = Description, Links = Links };
            courseInstance.Lessons.Add( lesson );

            db.SaveChanges();
            return RedirectToAction( "CourseInstance", new { id = id } );
        }
        public ActionResult EditLesson( int courseInstanceId, int id, Lesson editedLesson )
        {
            Lesson lesson = db.Lesson.Where( l => l.ID == id ).First();
            if( lesson == null ) {
                return HttpNotFound();
            }

            CourseInstance courseInstance = db.CourseInstance.Where( c => c.ID == courseInstanceId ).First();
            if( courseInstance.BaseCourse.Teachers.Where( t => User.Identity.Name == t.UserName ).FirstOrDefault() == null && !User.IsInRole( "admin" ) ) {
                ViewBag.Message = "У вас нет прав на редактирование этих материалов";
                return View( "Error" );
            }

            lesson.Name = editedLesson.Name;
            lesson.Description = editedLesson.Description;
            lesson.Links = editedLesson.Links;

            if( !ModelState.IsValid ) {
                ViewBag.CourseId = courseInstanceId;
                return View( lesson );
            }

            db.SaveChanges();

            return RedirectToAction( "CourseInstance", new { id = courseInstanceId } );
        }