public async Task <IDataResult <long> > AddAsync(AddLessonModel addLessonModel) { var validation = new LessonModelValidator().Valid(addLessonModel); if (!validation.Success) { return(new ErrorDataResult <long>(validation.Message)); } var lessonDomain = LessonDomainFactory.Create(addLessonModel); lessonDomain.Add(); var lessonEntity = lessonDomain.Map <LessonEntity>(); addLessonModel.LessonGroupTypes.ForEach(x => { var domain = LessonGroupDomainFactory.Create(x, lessonEntity.LessonId); lessonEntity.LessonGroups.Add(domain.Map <LessonGroupEntity>()); }); await LessonRepository.AddAsync(lessonEntity); await DatabaseUnitOfWork.SaveChangesAsync(); return(new SuccessDataResult <long>(lessonEntity.LessonId)); }
public static LessonDomain Create(AddLessonModel addLessonModel) { return(new LessonDomain( addLessonModel.Name, addLessonModel.LessonCode, addLessonModel.AKTS, addLessonModel.LessonType, addLessonModel.WeeklyHour, addLessonModel.SemesterType, addLessonModel.Credit )); }
public IActionResult exportSubject() { model = TempData.MyGet <AddLessonModel>("model"); if (model == null) { toastNotification.AddWarningToastMessage("Beklenmeyen Bir Hata Oluştu!"); return(View()); } toastNotification.AddSuccessToastMessage("Ders Ve Konu Kayıtları Başarıyla Gerçekleşti!"); return(View(model)); }
public IActionResult addInstructorLesson(int id) { Teacher teacher = instructorManager.Find(x => x.id == id); branch_TeacherList = branch_TeacherManager.List().Where(x => x.teacherid == id).ToList(); AddLessonModel addLessonModel = new AddLessonModel(); addLessonModel.TeacherId = id; addLessonModel.name = teacher.name; addLessonModel.surname = teacher.surname; lessonManager.List().Where(x => x.isFull != true).ToList().ForEach(x => addLessonModel.selectListLesson.Add(new SelectListItem(x.name, x.id.ToString()))); branch_TeacherList.ForEach(x => addLessonModel.selectListBranch.Add(new SelectListItem(x.branchName, x.branchid.ToString()))); return(View(addLessonModel)); }
public IActionResult addInstructorLesson(AddLessonModel addLessonModel) { _IRedisCacheService.GetLessons().Where(x => x.isFull != true).ToList().ForEach(x => addLessonModel.selectListLesson.Add(new SelectListItem(x.name, x.id.ToString()))); branch_TeacherList = branch_TeacherManager.List().Where(x => x.teacherid == addLessonModel.TeacherId).ToList(); branch_TeacherList.ForEach(x => addLessonModel.selectListBranch.Add(new SelectListItem(x.branchName, x.branchid.ToString()))); if (addLessonModel != null) { Validation <Subject> valid = subjectManager.Insert(addLessonModel); if (valid.ErrorList.Count == 0) { _IRedisCacheService.GetAllRemove(); Teacher teacher = instructorManager.List().Find(x => x.id == addLessonModel.TeacherId); addLessonModel.name = teacher.name; addLessonModel.surname = teacher.surname; if (addLessonModel.isPDF) { TempData.MyPut("model", addLessonModel); return(RedirectToAction("exportSubject", "ExportPDF")); } else { toastNotification.AddSuccessToastMessage("Ders Ve Konu Kayıtları Başarıyla Gerçekleşti!"); return(RedirectToAction("addInstructorLesson", "SelectLesson", new { id = addLessonModel.TeacherId })); } } else { valid.ErrorList.ForEach(x => toastNotification.AddWarningToastMessage(x)); return(RedirectToAction("addInstructorLesson", new { id = addLessonModel.TeacherId })); } } else { toastNotification.AddWarningToastMessage("Ders Ve Konu Ekleme İşlemi Sırasında Bir Hata Meydana Geldi!"); return(RedirectToAction("addInstructorLesson", new { id = addLessonModel.TeacherId })); } }
public async Task <IActionResult> AddAsync(AddLessonModel addLessonModel) { var result = await LessonService.AddAsync(addLessonModel); return(new ActionIResult(result)); }
public Validation <Subject> Insert(AddLessonModel addLessonModel) { int countSubject = 0; int countLesson = 0; Branch branch = null; Lessons lesson = null; Teacher teacher = null; if (addLessonModel.branch != 0 && addLessonModel.lesson != 0) { branch = branchManager.Find(x => x.id == addLessonModel.branch); lesson = lessonManager.Find(x => x.id == addLessonModel.lesson); teacher = instructorManager.Find(x => x.id == addLessonModel.TeacherId); } else { valid.ErrorList.Add("Lütfen Tüm Alanları Doldurduğunuzdan Emin Olun!"); return(valid); } for (int i = 0; i < addLessonModel.text.Length; i++) { if (addLessonModel.title[i] != null && addLessonModel.text[i] != null && addLessonModel.subjectStart[i] != null && addLessonModel.subjectFinish[i] != null) { } else { valid.ErrorList.Add("Lütfen Tüm Alanları Doldurduğunuzdan Emin Olun!"); return(valid); } } lesson.ownerBranch = branch.name; lesson.ownerTeacherName = teacher.name; lesson.ownerTeacherSurname = teacher.surname; lesson.teacherid = teacher.id; lesson.branchid = branch.id; lesson.isFull = true; lesson.teacher = teacher; for (int i = 0; i < addLessonModel.text.Length; i++) { Subject subject = new Subject(); subject.title = addLessonModel.title[i].ToUpper(); subject.text = addLessonModel.text[i].MyFirstLetterCapital(); subject.subjectStart = addLessonModel.subjectStart[i].Value; subject.subjectFinish = addLessonModel.subjectFinish[i].Value; subject.Lesson = lesson; lesson.subject.Add(subject); subject.CreatedOn = DateTime.Now; subject.ModifiedOn = DateTime.Now; lesson.ModifiedOn = DateTime.Now; countSubject = base.Insert(subject); countLesson = lessonManager.Update(lesson); if (countSubject < 0 && countLesson < 0) { break; } } if (countSubject < 0 && countLesson < 0) { valid.ErrorList.Add("Kayıt Oluşturma Sırasında Bir Hata Meydana Geldi!"); return(valid); } return(valid); }