BetterCms.Module.Blog.Services.DefaultBlogMLService.ImportAuthors C# (CSharp) Method

ImportAuthors() private method

private ImportAuthors ( BlogMLBlog authors, IList createdAuthors, List blogs ) : Guid>.IDictionary
authors BlogMLBlog
createdAuthors IList
blogs List
return Guid>.IDictionary
        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;
        }