public IActionResult RegisterFuelForm(FuelFormInputModel fuelInputModel) { if (this.ModelState.IsValid) { this.fuelService.AddFuelForm(fuelInputModel); } else { return(this.View()); } return(this.RedirectToAction("Index", "Home")); }
public void AddFuelForm(FuelFormInputModel fuelFormInputModel) { var outboundFlight = this.flightService.GetOutboundFlightByFlightNumber(fuelFormInputModel.FlightNumber); if (outboundFlight.Aircraft != null) { var newFuelForm = this.mapper.Map <FuelForm>(fuelFormInputModel); newFuelForm.Aircraft = outboundFlight.Aircraft; newFuelForm.AircraftId = outboundFlight.AircraftId; this.dbContext.FuelForms.Add(newFuelForm); this.dbContext.SaveChanges(); outboundFlight.Aircraft.FuelForm = newFuelForm; outboundFlight.Aircraft.FuelFormId = newFuelForm.Id; } }