Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateCar([FromRoute] int id, [FromBody] UpdateRentalCarDto updateRentalCarDto)
        {
            if (await _carService.UpdateCar(id, updateRentalCarDto))
            {
                return(NoContent());
            }

            return(NotFound());
        }
Ejemplo n.º 2
0
        public async Task <bool> UpdateCar(int id, UpdateRentalCarDto toUpdate)
        {
            var foundCar = await _repository.GetCarByIdAsync(id);

            if (foundCar == null)
            {
                _logger.LoggMessage($"Car with id: {id} was not found. Couldn't update.");
                return(false);
            }

            _mapper.Map(toUpdate, foundCar);
            _repository.UpdateCar(foundCar);
            await _repository.SaveChanges();

            _logger.LoggMessage($"Car with id: {id} was updated.");

            return(true);
        }