private async Task <AuthorProfile> CreateAuthorProfile(AddAuthorCommand message) { var socialHandles = new SocialHandles(message.LinkedIn, message.GitHub); var authorProfile = new AuthorProfile(message.FirstName, message.LastName, message.About); authorProfile.WithSocialHandles(socialHandles).WithResumeUri(message.ResumeUri); if (message.ImageId != null) { var image = await _dbContext.Images.FindAsync(message.ImageId); authorProfile.WithImage(image); } return(authorProfile); }
private async Task UpdateAuthorProfile(Author author, UpdateAuthorCommand message) { var socialHandles = new SocialHandles(message.LinkedIn, message.GitHub); if (author.AuthorProfile.SocialHandles != null) { _dbContext.Entry(author.AuthorProfile.SocialHandles).State = EntityState.Modified; } author.AuthorProfile.Update(message.FirstName, message.LastName, message.About) .WithSocialHandles(socialHandles) .WithResumeUri(message.ResumeUri); if (message.ImageId != null) { await CreateImage(author, message); } if (message.Experiences != null) { await CreateExperiences(message, author); } }