Esempio n. 1
0
        public async Task <ActionResult> PartialFlightUpdateAsync(int id, JsonPatchDocument <FlightUpdateDto> patchDoc)
        {
            var flightModelFromRepo = await _repository.GetByIdAsync(id);

            if (flightModelFromRepo == null)
            {
                return(NotFound());
            }

            var flightToPatch = _mapper.Map <FlightUpdateDto>(flightModelFromRepo);

            patchDoc.ApplyTo(flightToPatch, ModelState);

            if (!TryValidateModel(flightToPatch))
            {
                return(ValidationProblem(ModelState));
            }

            _mapper.Map(flightToPatch, flightModelFromRepo);
            _repository.Update(flightModelFromRepo);

            await _repository.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 2
0
 public void EditFlight(Models.Flight flight)
 {
     flightRepo.Update(flight);
 }