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 CreateAsync() { var test = new TestCreateDto("test3"); var result = await _testAppService.CreateAsync(test); result.Name.ShouldNotBeNull(); }
public ActionResult <TestReadDto> CreateTest(TestCreateDto testCreateDto) { var testModel = _mapper.Map <Test>(testCreateDto); _repository.CreateTest(testModel); //Insert data into database _repository.SaveChanges(); //Save the changes var testReadDto = _mapper.Map <TestReadDto>(testModel); // To show 201 status and show URI of the data in header return(CreatedAtRoute(nameof(GetTestById), new { id = testReadDto.id }, testReadDto)); //Confusing *** }
public async Task <ActionResult <TestReadDto> > CreateTestAsync(TestCreateDto testCreateDto) { var testModel = _mapper.Map <Test>(testCreateDto); _repository.CreateTest(testModel); _repository.SaveChanges(); var testReadDto = _mapper.Map <TestReadDto>(testModel); // to make successful create return 201 //return await Task.FromResult(CreatedAtRoute(nameof(GetTestByIdAsync), new { Id = testReadDto.Id }, testReadDto)); //this returns 200 return(await Task.FromResult(Ok(testReadDto))); }
public Task <TestDto> CreateAsync(TestCreateDto dto) { return(_testAppService.CreateAsync(dto)); }