Пример #1
0
        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));
        }