public void Create(string name, int number, string description) { var lecture = _lectureRepository.GetLectureOrFail(name); lecture = new Lecture(name, number, description); _lectureRepository.AddLecture(lecture); }
public async Task <IActionResult> AddLecture(LectureViewModel objLecture) { if (ModelState.IsValid) { string uniqueFileName = Utility.ProcessUploadedFile(objLecture.Lecture_File, _hostingEnvironment, "Lectures"); var classSectionObj = await _tPClassReposiroty.GetClassSectionById(objLecture.Class_Id, objLecture.Section_Id); if (classSectionObj != null) { var classSubjectObj = await _tPClassReposiroty.GetClassSubjectById(classSectionObj.ClassSection_id, objLecture.Subject_Id); if (classSectionObj != null) { Lecture newLecture = new Lecture { Lecture_Name = objLecture.Lecture_Name, Lecture_Detail = objLecture.Lecture_Detail, Lecture_File = uniqueFileName, LecturePost_Date = objLecture.LecturePost_Date.ToString("yyyyMMdd"), //DateTime.Now.ToString(), Teacher_Id = HttpContext.Session.GetInt32("UserId") ?? 1, ClassSubject_Id = classSubjectObj.ClassSubject_Id }; int result = await _LectureRepository.AddLecture(newLecture); if (result == 1) { TempData["Success"] = " Lecture Added Successfully"; //return RedirectToAction("Index", "lecture", new { area = "teachers" }); return(RedirectToAction("subjects", "class", new { ClassSectionId = classSectionObj.ClassSection_id, area = "teachers" })); } else { TempData["Error"] = "Adding Lecture Failed"; ///return RedirectToAction("Index", "lecture", new { area = "teachers" }); return(RedirectToAction("subjects", "class", new { ClassSectionId = classSectionObj.ClassSection_id, area = "teachers" })); } } else { TempData["Error"] = "Class And Section Dont Have Seleceted Subject"; //return RedirectToAction("Index", "lecture", new { area = "teachers" }); return(RedirectToAction("subjects", "class", new { ClassSectionId = classSectionObj.ClassSection_id, area = "teachers" })); } } else { TempData["Error"] = "Class With Section Didn't Find"; //return RedirectToAction("Index", "lecture", new { area = "teachers" }); return(RedirectToAction("subjects", "class", new { ClassSectionId = classSectionObj.ClassSection_id, area = "teachers" })); } } return(View()); }
public bool SaveLecture(Lecture lecture) { return(_lectureRepository.AddLecture(lecture)); }