Inheritance: DbContext
Example #1
0
 public async Task<JToken> Previous()
 {
     using (var db = new PlayrContext())
     {
         var email = Membership.GetUser().Email;
         var userToken = db.UserTokens.FirstOrDefault(u => u.Email == email);
         if (userToken != null)
         {
             var client = new HttpClient();
             var request = new HttpRequestMessage(HttpMethod.Post, Helpers.BuildApiUrl("/previous"));
             request.Headers.Add("x-playr-token", userToken.Token);
             var response = await client.SendAsync(request);
             response.EnsureSuccessStatusCode();
             return await response.Content.ReadAsAsync<JToken>();
         }
     }
     return null;
 }
Example #2
0
 public static HttpRequestMessage CreateRequest(HttpMethod method, string Url, bool includeUserToken)
 {
     var request = new HttpRequestMessage(method, Url);
     if (includeUserToken)
     {
         using (var db = new PlayrContext())
         {
             var email = Membership.GetUser().Email;
             var userToken = db.UserTokens.FirstOrDefault(u => u.Email == email);
             if (userToken != null)
             {
                 request.Headers.Add("x-playr-token", userToken.Token);
             }
         }
     }
     return request;
 }