private IDictionary<string, Guid> ImportAuthors(BlogMLBlog.AuthorCollection authors, IList<Author> createdAuthors, List<BlogMLPost> blogs)
{
var dictionary = new Dictionary<string, Guid>();
if (authors != null)
{
foreach (var authorML in authors)
{
if (!blogs.Any(b => b.Authors != null && b.Authors.Cast<BlogMLAuthorReference>().Any(c => c.Ref == authorML.ID)))
{
continue;
}
var id = repository
.AsQueryable<Author>()
.Where(a => a.Name == authorML.Title)
.Select(a => a.Id)
.FirstOrDefault();
if (id.HasDefaultValue())
{
var author = new Author { Name = authorML.Title };
repository.Save(author);
createdAuthors.Add(author);
id = author.Id;
}
dictionary.Add(authorML.ID, id);
}
}
return dictionary;
}