public async Task <DeleteResult> Handle(DeleteTimeTableCommand request, CancellationToken cancellationToken) { var timeTableModel = await _timeTableRepository.GetAsync(e => e.Id == request.Id); _timeTableRepository.Remove(timeTableModel); if (await _timeTableRepository.SaveChangesAsync() == 0) { throw new ApplicationException("Deletion failed"); } await _mediator.Publish(new TimeTableDeletedEvent(timeTableModel.Id), cancellationToken); return(new DeleteResult(true)); }