示例#1
0
        private async Task <Author> GetRandomAuthorAsync(BookContext context)
        {
            var firstName = _nameService.GetFirstName();
            var lastName  = _nameService.GetLastName();

            var author = await context.Authors.Where(a => a.FirstName == firstName && a.LastName == lastName).FirstOrDefaultAsync();

            if (author != null)
            {
                return(author);
            }

            return(new Author
            {
                LastName = lastName,
                FirstName = firstName,
                BirthDate = _nameService.GetBirthDate(),
            });
        }