public async Task <IActionResult> AddFlightPlane(AddFlightPlaneVM vm) { //get flight seat details to calc default seats remain var flightSeatTypeDetails = await _adminRepo.GetFlightSeatTypeDetails(vm.Flight.FlightSeatTypeID); vm.Flight.SeatsRemain = (Int16)((flightSeatTypeDetails.NumSeatsCenter + flightSeatTypeDetails.NumSeatsLeft + flightSeatTypeDetails.NumSeatsRight) * flightSeatTypeDetails.NumRows); //update Flight var result = await _adminRepo.UpdateFlightPlane(vm.Flight); return(RedirectToAction(nameof(ViewAllFlights), "Admin", null)); }
public async Task <IActionResult> AddFlightPlane(int flightId) { var vm = new AddFlightPlaneVM { Flight = await _flightRepo.GetByFlightId(flightId), //Plane = new Plane (), FlightSeatTypes = (await _globalRepo.GetAll <FlightSeatType>(FlightSeatType.tableName)).Select(s => new SelectListItem { Value = s.ID.ToString(), Text = "Rows: " + s.NumRows + ", Left: " + s.NumSeatsLeft + ", Center: " + s.NumSeatsCenter + ", Right: " + s.NumSeatsRight }) }; if (vm.Flight.PlaneID != null && vm.Flight.PlaneID > 0) { vm.Plane = await _flightRepo.GetPlaneByFlightId(flightId); } else { vm.Plane = new Plane(); } return(View(vm)); }