public async Task <IActionResult> UpdateFlightAsync(int id, FlightUpdateDto flightUpdateDto) { if (id != flightUpdateDto.Id) { return(BadRequest()); } var flightFromRepo = await _repository.GetByIdAsync(id); if (flightFromRepo == null) { return(NotFound()); } _mapper.Map(flightUpdateDto, flightFromRepo); //_repository.UpdateFlight(flightFromRepo.Value); // this is achieved by the previous code try { await _repository.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if ((await _repository.GetByIdAsync(id)) == null) { return(NotFound()); } } return(NoContent()); }