Пример #1
0
        public async Task <IActionResult> EditFlight(int flightId)
        {
            var countries = await _globalRepo.GetAll <Country>(Country.tableName);

            var flightVM = new AddFlightVM
            {
                Flight    = await _flightRepo.GetByFlightId(flightId),
                Countries = countries.Select(s => new SelectListItem {
                    Value = s.ID.ToString(), Text = s.CountryName, Selected = true
                })
            };

            flightVM.OriginCountryID = _countryRepo.GetLocById(flightVM.Flight.OriginLocID).Result.CountryID;
            flightVM.CitySelectList1 = (await _countryRepo.GetCitiesByCountryId(flightVM.OriginCountryID)).Select(s => new SelectListItem {
                Value = s.ID.ToString(), Text = s.City, Selected = true
            });

            flightVM.DestCountryID   = _countryRepo.GetLocById(flightVM.Flight.DestLocID).Result.CountryID;
            flightVM.CitySelectList2 = (await _countryRepo.GetCitiesByCountryId(flightVM.DestCountryID)).Select(s => new SelectListItem {
                Value = s.ID.ToString(), Text = s.City, Selected = true
            });

            flightVM.DepartDate = flightVM.Flight.DepartDateTime.Date;
            flightVM.DepartTime = flightVM.Flight.DepartDateTime;
            flightVM.ArrDate    = flightVM.Flight.ArrDateTime.Date;
            flightVM.ArrTime    = flightVM.Flight.ArrDateTime;
            return(View(flightVM));
        }