public async Task <CreateTimeslotResponse> Handle(CreateTimeslotCommand request, CancellationToken cancellationToken)
        {
            var teacher = await _tpp.GetTeacherWithTimeslotsById(request.TeacherId);

            var calendar = await _cpp.GetByIdAsync(request.CalendarId);

            var timeslot = new Timeslot(request.StartTime, request.EndTime, teacher, calendar);

            teacher.AddTimeslot(timeslot);
            await _tpp.Update(teacher);

            return(new CreateTimeslotResponse {
                Id = timeslot.Id
            });
        }
Exemplo n.º 2
0
        public async Task <ICollection <Timeslot> > Handle(GetAvailableTimeslotsQuery request, CancellationToken cancellationToken)
        {
            var teacher = await _tpp.GetTeacherWithTimeslotsById(request.TeacherId);

            return(teacher.AvailableTimeslots);
        }