public IResult Add(Lesson lesson) { if (lesson.LessonName.Length < 2) { return(new ErrorResult(Messages.LessonNameTooShort)); } _lessonDal.Add(lesson); return(new SuccessResult(Messages.LessonAddedSuccessfully)); }
public void Add(LessonDto lessonDto) { var lesson = new Lesson() { Name = lessonDto.Name, }; _lessonDal.Add(lesson); _lessonDal.Save(); }
public void Add(Lesson entity) { if (Validation(entity)) { return; } if (_lessonDal.GetAll().Any(p => p.LessonCode.Equals(entity.LessonCode))) { Message.Error("Ders Kodu Mevcut!"); return; } try { _lessonDal.Add(entity); Message.Info("Ders eklendi."); } catch (Exception exp) { Message.Error("Ders eklenirken hata oluştu!\n" + exp.Message); } }
public IResult AddLesson(Lesson lesson, int userId) { if (_lessonDal.IsStudent(userId)) { return(new ErrorResult(Messages.UnauthorizedAccess)); } var AlreadyInDb = _lessonDal.Get(l => l.LessonCRN == lesson.LessonCRN); if (AlreadyInDb != null) { return(new ErrorResult(Messages.LessonAlreadyInDb)); } bool result = _lessonDal.Add(lesson); if (result == true) { return(new SuccessResult(Messages.LessonAddSucceed)); } else { return(new ErrorResult(Messages.LessonAddFailed)); } }