public async Task CreateMember(Guid chapterId, CreateMemberProfile profile) { await ValidateMemberProfile(chapterId, profile); ValidateMemberImage(profile.Image.MimeType, profile.Image.ImageData); Member existing = await _memberRepository.FindMemberByEmailAddress(profile.EmailAddress); if (existing != null) { return; } Member create = new Member(Guid.Empty, chapterId, profile.EmailAddress, profile.EmailOptIn, profile.FirstName, profile.LastName, DateTime.UtcNow, false, false, 0); Guid id = await _memberRepository.CreateMember(create); ChapterMembershipSettings membershipSettings = await _chapterRepository.GetChapterMembershipSettings(chapterId); MemberSubscription subscription = new MemberSubscription(id, SubscriptionType.Trial, create.CreatedDate.AddMonths(membershipSettings.TrialPeriodMonths)); await _memberRepository.UpdateMemberSubscription(subscription); MemberImage image = CreateMemberImage(id, profile.Image.MimeType, profile.Image.ImageData); await _memberRepository.AddMemberImage(image); IEnumerable <MemberProperty> memberProperties = profile.Properties .Select(x => new MemberProperty(Guid.Empty, id, x.ChapterPropertyId, x.Value)); await _memberRepository.UpdateMemberProperties(id, memberProperties); string activationToken = RandomStringGenerator.Generate(64); await _memberRepository.AddActivationToken(new MemberActivationToken(id, activationToken)); Chapter chapter = await _chapterRepository.GetChapter(chapterId); string url = _settings.ActivateAccountUrl.Interpolate(new Dictionary <string, string> { { "chapter.name", chapter.Name }, { "token", HttpUtility.UrlEncode(activationToken) } }); await _emailService.SendEmail(chapter, create.EmailAddress, EmailType.ActivateAccount, new Dictionary <string, string> { { "chapter.name", chapter.Name }, { "url", url } }); }