public ActionResult AddLecture1(Lecture lecture) { lectureService.InsertLecture(lecture); var lectureId = lectureService.GetLectureByNameAndCourseId(lecture.Title, lecture.CourseId).Id; if (Session["file"] as IEnumerable <HttpPostedFileBase> != null) { foreach (var image in Session["file"] as IEnumerable <HttpPostedFileBase> ) { imageService.UploadImageToDB(image, lectureId); } } return(RedirectToAction("Index", "Home")); }