public async Task <IEnumerable <ResupplyResponse> > CalculateResupplyRequiredForAllStarships(decimal distance) { var starships = await _starshipRepository.GetAllStarships(); var calculedResupplies = new List <ResupplyResponse>(); foreach (var starship in starships) { calculedResupplies.Add(CalculateResupplyStops(starship, distance)); } return(calculedResupplies); }
public async Task <ActionResult <IList <Starship> > > GetStarships() { var results = await _starshipRepository.GetAllStarships(); try { if (results.Count > 0 || results != null) { _logger.LogInformation("Getting starships from database"); return(Ok(results)); } else { _logger.LogInformation($"Could not get any starships from the database"); return(NotFound()); } } catch (Exception exception) { _logger.LogInformation($"Could not get any starships from the database"); return(StatusCode(StatusCodes.Status500InternalServerError, $"Database failure: {exception.Message}")); } }
public async Task <ActionResult <IEnumerable <Starship> > > GetStarships() { var starships = await _repository.GetAllStarships(); return(Ok(starships)); }