Example #1
0
        public ActionResult <CarReadDto> CreateCar(CarCreateDto carCreateDto)
        {
            var carModel = _mapper.Map <Car>(carCreateDto);

            _repository.CreateCar(carModel);
            _repository.SaveChanges();

            var carReadDto = _mapper.Map <CarReadDto>(carModel);

            return(CreatedAtRoute(nameof(GetCarById), new { Id = carReadDto.Id }, carReadDto));
        }