public async Task <ScheduleResponseModel> PutSchedule( int scheduleId, [FromForm] ScheduleRequestModel model, CancellationToken cancellationToken ) { cancellationToken.ThrowIfCancellationRequested(); var command = new UpdateScheduleCommand( scheduleId, model.SubjectId, model.TeacherId, model.StartTime, model.Duration, model.LessonType, model.AudienceNumber ); await _mediator.Send(command, cancellationToken); var query = new FindScheduleByIdQuery(scheduleId); var schedule = await _mediator.Send(query, cancellationToken); var response = _mapper.Map <ScheduleResponseModel>(schedule); return(response); }
public async Task <ScheduleResponseModel> GetSchedule(int scheduleId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var query = new FindScheduleByIdQuery(scheduleId); var schedule = await _mediator.Send(query, cancellationToken); if (schedule == null) { throw new NotFoundException(nameof(schedule), scheduleId); } var response = _mapper.Map <ScheduleResponseModel>(schedule); return(response); }