Example #1
0
        public async Task <TimeTableDto> Handle(CreateTimeTableCommand request, CancellationToken cancellationToken)
        {
            var timeTableModel = _timeTableDxos.MapCreateRequesttoTimeTable(request);

            _timeTableRepository.Add(timeTableModel);

            if (await _timeTableRepository.SaveChangesAsync() == 0)
            {
                throw new ApplicationException("Insertion to database failed");
            }

            await _mediator.Publish(new TimeTableCreatedEvent(timeTableModel.Id), cancellationToken);

            var timeTableDto = _timeTableDxos.MapTimeTableDto(timeTableModel);

            return(timeTableDto);
        }