public async Task <ActionResult> Delete(QuestionActionRequest request, CancellationToken cancel)
        {
            var command = new QuestionDeleteCommand(request.Id);
            var result  = await _mediator.ExecuteAsync <QuestionDeleteCommand, QuestionDeleteCommandResult>(command, User.GetAppIdentity(), cancel);

            return(RedirectToRoute("QuestionRead", new { id = result.Id, slug = result.Slug, action = "get" }));
        }
Esempio n. 2
0
        public async Task QuestionDeleteCommandTriggersEventToDeleteQuestionFromQueryDb()
        {
            //Arrange
            var command = new QuestionCreateCommand("Test Question 1");
            await _commandBus.Send(command);

            var questions = await _questionRepo.FindByAsync(q => q.Id == 1).ConfigureAwait(false);

            var question = questions.FirstOrDefault();

            //Act
            Assert.IsNotNull(question);

            var command2 = new QuestionDeleteCommand(1, 0);
            await _commandBus.Send(command2).ConfigureAwait(false);

            var questionAfterDelete = (await _questionRepo.FindByAsync(q => q.Id == 1).ConfigureAwait(false)).FirstOrDefault();

            //Act
            Assert.IsNull(questionAfterDelete);
        }