コード例 #1
0
        public static async Task <Author> Create(User user, AuthorProfile authorProfile, IAuthorValidator authorValidator)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (authorProfile == null)
            {
                throw new ArgumentNullException(nameof(authorProfile));
            }
            if (authorValidator == null)
            {
                throw new ArgumentNullException(nameof(authorValidator));
            }

            if (await authorValidator.Exists(user))
            {
                throw new InvalidOperationException("Only one author can be created per user.");
            }

            return(new Author(user, authorProfile));
        }
コード例 #2
0
 private Author(User user, AuthorProfile authorProfile)
 {
     User          = user;
     AuthorProfile = authorProfile;
 }