private void LoadAuthenticationTokens() { using (var context = new OAuthDataContext()) { var auth = context.OAuthAuthentication.FirstOrDefault(); if (auth == null) return; _accessToken = auth.AccessToken; _refreshToken = auth.RefreshToken; _tokenExpiry = auth.Expiry; _authorizeCode = auth.AuthorizeCode; context.SaveChanges(); } }
private void PersistAuthenticationTokens() { using (var context = new OAuthDataContext()) { context.Database.ExecuteSqlCommand("DELETE FROM [OAuthAuthentications]"); var item = new OAuthAuthentication(); item.AccessToken = _accessToken; item.RefreshToken = _refreshToken; item.Expiry = _tokenExpiry; item.AuthorizeCode = _authorizeCode; context.OAuthAuthentication.Add(item); context.SaveChanges(); } }