Esempio n. 1
0
 public virtual async Task <YearBounds> GetYearBoundsAsync(WebApiCredentials credentials, long patientId, CancellationToken ct)
 {
     return(await WebApiODataContainer.Using(_apiUrl, credentials)
            .GetAuthenticatedAsync <YearBounds>(
                container => string.Format("{0}({1})/.GetYearBounds", container.DPatient.ToString(), patientId),
                exception => { },
                ct));
 }
Esempio n. 2
0
        public async Task <IEnumerable <DMuscle> > GetMusclesAsync(WebApiCredentials credentials, CancellationToken ct)
        {
            ct.ThrowIfCancellationRequested();
            return(await WebApiODataContainer.Using(_apiUrl, credentials)
                   .ExecuteAuthenticated(
                       async container =>
            {
                ct.ThrowIfCancellationRequested();
                var query = container.DMuscle;

                return await query.GetAllPagesAsync();
            },
                       ct));
        }
Esempio n. 3
0
        public async Task <DPatient> GetPatientAsync(WebApiCredentials credentials, long id, CancellationToken ct)
        {
            ct.ThrowIfCancellationRequested();
            return(await WebApiODataContainer.Using(_apiUrl, credentials)
                   .ExecuteAuthenticated(
                       container =>
            {
                ct.ThrowIfCancellationRequested();
                var query = container.DPatient.Where(e => e.Id == id);

                return query.FirstOrDefault();
            },
                       ct));
        }
Esempio n. 4
0
 public async Task <ApplicationSettings> GetSettingsAsync(WebApiCredentials credentials, string userId, CancellationToken ct)
 {
     ct.ThrowIfCancellationRequested();
     return(await WebApiODataContainer.Using(_apiUrl, credentials)
            .ExecuteAuthenticated(
                container =>
     {
         ct.ThrowIfCancellationRequested();
         var query =
             container.ApplicationSettings.Where(
                 e => e.ApplicationId == credentials.ApplicationId && e.UserId == userId);
         return query.FirstOrDefault();
     },
                ct));
 }
Esempio n. 5
0
        public async Task <JavaScriptResult> ApiAuth(CancellationToken ct)
        {
            _credentials.OnBehalfOf = User.Identity.GetUserId();
            var auth = await WebApiODataContainer.Using(_apiUrl, _credentials)
                       .AuthenticateAsync(ct);

            var script = string.Format(@"var alsglance = alsglance || {{}}; alsglance.dashboard = alsglance.dashboard || {{}}; alsglance.apiClient =new alsglance.ApiClientImpl({{baseUri: '{1}',authToken: '{0}'}});" +
                                       "alsglance.applicationId='{2}';" +
                                       "alsglance.dashboard.userId='{3}';",
                                       auth.Authorization.AccessToken,
                                       _apiUrl,
                                       Settings.Default.ApplicationId,
                                       User.Identity.GetUserId());

            return(JavaScript(script));
        }