示例#1
0
        public async Task <ActionResult <CarDto> > PostCar(string carDto)
        {
            var dto = carDto.GetDto <CarDto>();

            if (dto == null)
            {
                BadRequest(ExceptionMessageHeaders.CanNotRecognizeInputModel);
            }

            var entity = _mapper.Map <Car>(dto);
            await _repository.AddAsync(entity).ConfigureAwait(false);

            await _unitOfWork.CommitAsync().ConfigureAwait(false);

            return(CreatedAtAction("GetCar", new { id = carUnit?.Id }, car));
        }