Ejemplo n.º 1
0
        public async Task CreateAnswer_AddItemToDb()
        {
            var countItemsImDataBase = await _context.Answers.CountAsync();

            await _service.CreateAsync(new AnswerDto()
            {
                Id = 3, IsCorrect = false, Text = "Answer_1", QuestionId = 1
            });

            _context.Answers.CountAsync().Result.Should().Be(countItemsImDataBase + 1);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(AnswerDto answerDto)
        {
            if (ModelState.IsValid)
            {
                await _answerService.CreateAsync(answerDto);

                return(RedirectToAction(nameof(Index), new { questionId = answerDto.QuestionId }));
            }

            ViewBag.Question = await _questionService.GetByIdAsync(answerDto.QuestionId);

            return(View(answerDto));
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> Put([FromBody] AnswerDto answer)
 {
     return(Success(await _answerService.CreateAsync(answer)));
 }
        public async Task <IActionResult> Create(AnswerRequest answerRequest)
        {
            await _answerService.CreateAsync(answerRequest);

            return(Created("", ""));
        }