public async Task <TestDto> CreateAsync([NotNull] TestCreateDto dto) { var entity = ObjectMapper.Map <TestCreateDto, TestEntity>(dto); var test = await _testService.CreateAsync(entity); return(ObjectMapper.Map <TestEntity, TestDto>(test)); }
public async Task CreateTest_AddItemToDb() { var countItemsImDataBase = await _context.Tests.CountAsync(); await _service.CreateAsync(new TestDto() { Id = 3, ThemeId = 1, Questions = new List <QuestionDto>(), Title = "Test_1" }); _context.Tests.CountAsync().Result.Should().Be(countItemsImDataBase + 1); }
public async Task <IActionResult> Create(TestDto testDto) { if (ModelState.IsValid) { await _testService.CreateAsync(testDto); return(RedirectToAction(nameof(Index), new { themeId = testDto.ThemeId })); } ViewBag.Theme = await _themeService.GetByIdAsync(testDto.ThemeId); return(View(testDto)); }
public async Task Create_Tenant_Name_Can_Not_Duplicate() { var test1 = new TestEntity("test1"); await Assert.ThrowsAsync <UserFriendlyException>(async() => await _testService.CreateAsync(test1)); }