Пример #1
0
        public Session CreateNewSession(Account account)
        {
            var newSessionId = IdGenerationHelper.GetNewId((sessionId) => dataAccess.GetSession(sessionId) == null);

            var entity = new Session
            {
                AccountId   = account.AccountId,
                SessionId   = newSessionId,
                CreatedDate = DateTime.UtcNow,
                Invalidated = false
            };

            dataAccess.AddSession(entity);

            return(entity);
        }
Пример #2
0
        public Account CreateAccount(GoogleUserData googleData)
        {
            var newAccountId = IdGenerationHelper.GetNewId((accountId) => dataAccess.GetAccountById(accountId) == null);

            var account = new Account
            {
                AccountId   = newAccountId,
                GoogleId    = googleData.Id,
                Name        = googleData.Name,
                Email       = googleData.Email,
                CreatedDate = DateTime.UtcNow
            };

            dataAccess.AddNewAccount(account);
            Log.Information($"Added new account. id={account.AccountId}");
            return(account);
        }