private RoverAPIData GetRoverAPIData(string marsRoverAPIURL)
        {
            RoverAPIData apiData  = null;
            var          response = webApiService.Get($"{marsRoverAPIURL}").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonString = response.Content.ReadAsStringAsync().Result;
                apiData = JsonConvert.DeserializeObject <RoverAPIData>(jsonString);
            }

            return(apiData);
        }
        /// <summary>
        /// Load the text file and download all the rover image data from the nasa's site.
        /// </summary>
        /// <param name="authPassKey">already exchanged secure key</param>
        /// <returns></returns>
        public void LoadNewDates(UploadedFile uploadedFile)
        {
            string[] newDates = null;
            if (_appSettings.AuthPassKey.ToLowerInvariant().Trim().Equals(uploadedFile.AuthKey.ToLowerInvariant().Trim()))
            {
                //check for "dates.txt"
                newDates = _fileWrapper.Get(uploadedFile.DatesFile);

                Parallel.ForEach(newDates, newDate =>
                {
                    DateTime date;
                    string[] formats = { "MMMM dd, yyyy", "MMM dd, yyyy", "M/d/yyyy", "MM/dd/yyyy", "M/dd/yyyy hh:mm" };
                    if (DateTime.TryParse(newDate, out date) || DateTime.TryParseExact(newDate, formats, new System.Globalization.CultureInfo("en-US"), System.Globalization.DateTimeStyles.None, out date))
                    {
                        string formattedDate       = date.ToString("yyyy-MM-dd");
                        string newDateFolder       = Path.Combine(_appSettings.RoverDateImagesPath, formattedDate);
                        string newDateFolderThumbs = Path.Combine(newDateFolder, "thumbnails");
                        if (!_fileWrapper.DirectoryExists(newDateFolder))
                        {
                            _fileWrapper.CreateDirectory(newDateFolder);
                            _fileWrapper.CreateDirectory(newDateFolderThumbs);

                            RoverAPIData dateData = GetRoverAPIData(_appSettings.MarsRoverAPIURL.Replace("{earth_date}", formattedDate));

                            foreach (Photo photo in dateData.photos ?? new List <Photo>())
                            {
                                string imageFile  = Path.Combine(newDateFolder, $"{photo.id}_{photo.camera.full_name}.JPG");
                                string thumbsFile = Path.Combine(newDateFolderThumbs, $"{photo.id}T_{photo.camera.full_name}.JPG");
                                if (DownloadImage(photo.img_src, imageFile))
                                {
                                    _fileWrapper.ResizeImageFile(imageFile, thumbsFile, 200, 200);
                                }
                            }
                        }
                    }
                });
            }
        }