Exemplo n.º 1
0
        public async Task AddAsync(Guid userId, string name, string category, string grade, decimal pricePerHour)
        {
            var teacher = await _teacherRepository.GetOrFailAsync(userId);

            var les = await GetAsync(userId, name, category, grade);

            if (les != null)
            {
                throw new ServiceException(ServiceErrorCodes.LessonAlreadyExists, "Lesson with specific name, category and grade already exists.");
            }

            var subjectDetails = await _subjectProvider.GetAsync(name, category);

            var subject = Subject.Create(subjectDetails.Name, subjectDetails.Category);
            var lesson  = new Lesson(subject, grade, pricePerHour);

            await _teacherRepository.AddLesson(teacher, lesson);
        }
Exemplo n.º 2
0
 public async Task AddLesson(int teacherId, int subjectId) => await _repository.AddLesson(teacherId, subjectId);