private bool EditRoute(RouteModel route) { var editWindow = new EditRouteWindow(); var ctx = (EditRouteViewModel)editWindow.DataContext; var routeCopy = new RouteModel(); CopyFields(route, routeCopy); ctx.Route = routeCopy; ctx.Airports = _airportService.GetAllAirports(); ctx.Carriers = _carrierService.GetAllCarriers(); routeCopy.AirportDepart = ctx.Airports.Single(a => a.Id == routeCopy.AirportDepart.Id); routeCopy.AirportArrive = ctx.Airports.Single(a => a.Id == routeCopy.AirportArrive.Id); if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(routeCopy); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } CopyFields(routeCopy, route); _routeService.EditRoute(route); return(true); }
public IActionResult GetAllAirports() { IEnumerable <Airport> airports = _airportService.GetAllAirports(); if (airports == null) { return(NotFound()); } // Enumerate through each single Aircraft and call CreateLinks method. airports = airports.Select(airport => { airport = CreateLinks(airport); return(airport); }); Link link = new Link { Href = Url.Link(nameof(GetAllAirports), null), Relation = "self", Method = Link.GetMethod }; var response = new { Value = airports, Links = link }; return(Ok(response)); }
public IActionResult Airport() { var airports = _airportService.GetAllAirports(); return(View(airports)); }
public async Task <IActionResult> GetAllAirports() { var result = await airportService.GetAllAirports(); return(this.FromResult(result)); }
public async Task <IActionResult> GetAllAirports() { var airports = await _airportService.GetAllAirports(); return(Ok(airports)); }
/// <summary> /// Gets all airports. /// </summary> /// <returns>List of airports</returns> public IEnumerable <AirportViewModel> Get() { return(ApiExceptionHelper.WrapException(() => { _logger.Info("Get all airports."); var airportViewModels = Mapper.Map <IEnumerable <Airport>, IEnumerable <AirportViewModel> >(_airportService.GetAllAirports()); _logger.Info("Returned all airports. Airports='{0}'", airportViewModels.ToJson()); return airportViewModels; }, _logger)); }