예제 #1
0
 public void UpdateEdaphobaseInfo()
 {
     try
     {
         var taxons = _infContext.Taxon.Where(tax => tax.EdaphobaseId != null).ToList();
         foreach (Taxon tax in taxons)
         {
             if (tax.EdaphobaseId != null)
             {
                 List <string> synonyms = doEdaphoRequest(edaphoApi, tax.EdaphobaseId.ToString());
                 if (synonyms != null)
                 {
                     synonyms.RemoveAll(syn => syn == tax.Genus.TaxonName);
                     //sanitize edaphobase input double whitespaces
                     synonyms.ForEach(syn => Regex.Replace(syn, @"\s+", " "));
                     tax.Synonyms = JsonConvert.SerializeObject(synonyms);
                 }
             }
         }
         _infContext.UpdateRange(taxons);
         _infContext.SaveChanges();
         Logger.Info("-- Done Updating Edaphobase Info.");
     } catch (Exception e)
     {
         Logger.Error(e, "-- Error Updating Edaphobase Info");
     }
 }