Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public async Task CreateAsync()
        {
            var test = new TestCreateDto("test3");

            var result = await _testAppService.CreateAsync(test);

            result.Name.ShouldNotBeNull();
        }
Exemplo n.º 3
0
        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 ***
        }
Exemplo n.º 4
0
        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)));
        }
Exemplo n.º 5
0
 public Task <TestDto> CreateAsync(TestCreateDto dto)
 {
     return(_testAppService.CreateAsync(dto));
 }