public async Task <int> SaveAllRoverMarsPhotosAsync(string earthDate) { var photosCount = 0; IList <Rover> rovers; try { rovers = _marsRoverDbRepository.GetRovers().Result; } catch (Exception ex) { _logger.LogError($"Failed to retrieve rovers. Error: {ex.Message}"); throw; } foreach (var rover in rovers) { try { photosCount += await SaveRoverMarsPhotosAsync(rover, earthDate); } catch (Exception ex) { _logger.LogError($"Failed to save mars photos for rovers {rover.Name}. Error: {ex.Message}"); throw; } } return(photosCount); }
public async Task <IActionResult> GetRovers() { var rovers = await _marsRoverDbRepository.GetRovers(); return(Ok(rovers)); }