示例#1
0
        public async Task <UserData> GetUserData(string externalUserId)
        {
            var userData = await memoryCache.GetOrCreateAsync(externalUserId, async (e) =>
            {
                e.SlidingExpiration  = TimeSpan.FromMinutes(5);
                e.AbsoluteExpiration = DateTime.Now.AddHours(8);

                var user = await userRepository.GetUser(externalUserId);

                return(user);
            });

            return(userData);
        }
示例#2
0
        public async Task <UserRegistrationResult> TryRegisterUser(UserRegistrationData registrationData)
        {
            var userData = await userRepository.GetUser(registrationData.ExternalId);

            if (userData == null)
            {
                userData = await userRepository.RegisterUser(registrationData);

                await userRepository.SaveGoogleMap(userData, registrationData.ExternalId);

                return(new UserRegistrationResult {
                    NewUserRegistered = true, UserData = userData
                });
            }
            return(new UserRegistrationResult {
                UserData = userData
            });
        }