private ApiKeyLoginResponseContent GetAuthorization(ApiKeys key) { DateTime now = DateTime.UtcNow; ApiKeyLoginResponseContent response = (ApiKeyLoginResponseContent)Session["authorization"]; if (response == null || response.Expires <= now) { response = (ApiKeyLoginResponseContent)apiService.ApiKeyLogin(key.ApiKey, key.AppId); Session["authorization"] = (ApiKeyLoginResponseContent)response; } return(response); }
public async Task <ApiKeyLoginResponseContent> GetAuthorizationAsync(ApiKeys key) { DateTime now = DateTime.Now; ApiKeyLoginResponseContent response = (ApiKeyLoginResponseContent)HttpContext.Current.Session["authorization"]; if (response == null || response.Expires <= now) { response = (ApiKeyLoginResponseContent)await apiService.ApiKeyLoginAsync(key); HttpContext.Current.Session["authorization"] = (ApiKeyLoginResponseContent)response; } return(response); }