public async Task UpdateAsync(long id, UpdateFlightRequestModel model) { var flight = await _context.Flights.SingleOrDefaultAsync(f => f.Id == id); if (model.ArrivalTime != null) { flight.ArrivalTime = model.ArrivalTime; } if (model.DepartureTime != null) { flight.DepartureTime = model.DepartureTime; } if (model.TicketPrice != null) { flight.TicketPrice = model.TicketPrice.Value; } if (model.NumberOfChangeovers != null) { flight.NumberOfChangeovers = model.NumberOfChangeovers.Value; } if (model.TravelLength != null) { flight.TravelLength = model.TravelLength.Value; } await _context.SaveChangesAsync(); }
public IHttpActionResult Update(int id, UpdateFlightRequestModel flight) { if (id <= 0) { return(this.BadRequest(ErrorMessages.INVALID_ID)); } if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } var flightToUpdate = Mapper.Map <LegInstance>(flight); var updatedFlight = this.legInstancesServices.UpdateLegInstance(id, flightToUpdate); if (updatedFlight == null) { return(this.NotFound()); } return(this.Ok(updatedFlight.Id)); }
public Task UpdateAsync(long id, UpdateFlightRequestModel model) { return(_flightRepository.UpdateAsync(id, model)); }
public Task Put(long id, [FromBody] UpdateFlightRequestModel model) { return(_flightService.UpdateAsync(id, model)); }