Ejemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] CarViewModel car)
        {
            ValidationUtils.CheckViewModelNotIsNull(car);
            ModelState.CheckModelStateValidation();

            var carDTO = _mapper.Map <CarViewModel, CarDTO>(car);

            carDTO = await _carService.Update(carDTO);

            var editedCar = _mapper.Map <CarDTO, CarViewModel>(carDTO);

            return(Ok(editedCar));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] CarViewModel car)
        {
            ValidationUtils.CheckViewModelNotIsNull(car);
            ModelState.CheckModelStateValidation();

            var carDTO = _mapper.Map <CarViewModel, CarDTO>(car);

            carDTO = await _carService.Create(carDTO);

            var createdCar = _mapper.Map <CarDTO, CarViewModel>(carDTO);

            var uri = new Uri($"{HttpContext.Request.Host}{HttpContext.Request.Path.Value}");

            return(Created(uri, createdCar));
        }