示例#1
0
        public async Task <UserDto> CreateUserAsync(SignUpUserDto signUpUser)
        {
            var user = await _dbContext.TransactionAsync <UserDto>(typeof(User).Name, async (collection) =>
            {
                await _dbContext.Users.InsertOneAsync(new User
                {
                    EmailAddress = signUpUser.EmailAddress,
                    Username     = signUpUser.Username,
                    Password     = signUpUser.Password
                });

                var createdUser = await collection.Find(x => x.EmailAddress == signUpUser.EmailAddress).SingleAsync();

                return(createdUser);
            });

            return(user);
        }