Beispiel #1
0
            public async Task <Unit> Handle(CreateQuestionTypeCommand request, CancellationToken cancellationToken)
            {
                var entity = new QuestionType
                {
                    Id   = request.Id,
                    Name = request.Name
                };

                _context.QuestionType.Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                await _mediator.Publish(new QuestionTypeCreated { Id = entity.Id }, cancellationToken);

                return(Unit.Value);
            }
Beispiel #2
0
            public async Task <Unit> Handle(CreateAnswerCommand request, CancellationToken cancellationToken)
            {
                var entity = new Answer
                {
                    Id      = request.Id,
                    Text    = request.Text,
                    Correct = request.Correct
                };

                _context.Answer.Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                await _mediator.Publish(new AnswerCreated { Id = entity.Id }, cancellationToken);

                return(Unit.Value);
            }