コード例 #1
0
        public async Task RegisterUser(Guid UserAccountId, string WeChatKeyName)
        {
            var userAccount = await DataCustomerAccessor.OneAsync <UserAccountEntry>(x => x.Id == UserAccountId, "Roles", "WeChat", "WeChat.OpenIdMapping");

            await userAccountBusiness.SetRole(UserAccountId, UserRole);

            var customerAccount = await DataCustomerAccessor.OneAsync <CustomerAccount>(x => x.UserAccountId == UserAccountId);

            if (customerAccount == null)
            {
                customerAccount = new CustomerAccount
                {
                    Id            = Guid.NewGuid(),
                    CreateTime    = DateTime.Now,
                    Avatar        = userAccount.Avatar,
                    NickName      = userAccount.NickName,
                    OpenId        = userAccount.WeChat.OpenIdMapping.FirstOrDefault(x => x.Source == WeChatKeyName).OpenId,
                    UserAccountId = UserAccountId
                };
                await DataCustomerAccessor.Add(customerAccount);
            }
        }