public void SaveSynonym(Synonym synonym) { var synonymsToSave = parser.GetAllSynonymObjectsFromSynonym(synonym); foreach (var synonymItem in synonymsToSave) { repository.SaveSynonym(synonymItem); } ; }
public IEnumerable <Synonym> GetAllSynonymObjectsFromSynonym(Synonym synonym) { _ = synonym ?? throw new ArgumentNullException($"{nameof(synonym)} cannot be null"); List <Synonym> synonyms = new List <Synonym>(); synonyms.Add(synonym); synonyms.AddRange(synonym.Synonyms.Split(',').Select(x => new Synonym { Term = x, Synonyms = synonym.Term }).ToList()); return(synonyms); }