private void SynchInfusionApi(GlobalPreference value) { if (value is InfusionGlobalPreference) { return; } var preferences = value as InfusionGlobalPreference; var baseUrl = options.Value.BaseUrl; var apiUrl = options.Value.ApiUrl; var currentUserId = options.Value.CurrentUserId; var infusionSettings = ConvertInfusionPreferencesToSettings(preferences, currentUserId); var client = httpClientResolver.Resolve(); client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var token = this.accessTokenResolver.Resolve(); if (!string.IsNullOrWhiteSpace(token)) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); } var response = client.PostAsJsonAsync(apiUrl, infusionSettings).Result; response.EnsureSuccessStatusCode(); }
private void OnDeleted(GlobalPreference value) { using (log.Activity(m => m($"Execute {nameof(OnDeleted)} for {nameof(GlobalPreference)}[{value.Name}]"))) { log.Info($"Executed {nameof(OnDeleted)} for {nameof(GlobalPreference)}[{value.Name}]"); } }
private void OnUpdated(GlobalPreference value, GlobalPreference original) { using (log.Activity(m => m($"Execute {nameof(OnUpdated)} for {nameof(GlobalPreference)}[{value.Name}]"))) { SynchInfusionApi(value); log.Info($"Executed {nameof(OnUpdated)} for {nameof(GlobalPreference)}[{value.Name}]"); } }
//------------------------------------------------------------------------------------ /// <summary> /// Returns the user preference of the specified type. If this preference has never /// been set, null will be returned. /// </summary> //------------------------------------------------------------------------------------ public ObjType GetGlobalPreference <ObjType>(GlobalPreference preference) { if (GlobalPreferences.ContainsKey(preference)) { return((ObjType)GlobalPreferences[preference]); } return(default(ObjType)); }
public IHttpActionResult GetGlobalPreference(int id) { GlobalPreference globalPreference = db.GlobalPreferences.Find(id); if (globalPreference == null) { return(NotFound()); } return(Ok(globalPreference)); }
public IHttpActionResult DeleteGlobalPreference(int id) { GlobalPreference globalPreference = db.GlobalPreferences.Find(id); if (globalPreference == null) { return(NotFound()); } db.GlobalPreferences.Remove(globalPreference); db.SaveChanges(); return(Ok(globalPreference)); }
//------------------------------------------------------------------------------------ /// <summary> /// Sets the user preference of the specified type. /// </summary> //------------------------------------------------------------------------------------ public void SetGlobalPreference(GlobalPreference preference, object value) { if (GlobalPreferences == null) { GlobalPreferences = new Dictionary <GlobalPreference, object>(); } if (GlobalPreferences.ContainsKey(preference)) { GlobalPreferences[preference] = value; } else { GlobalPreferences.Add(preference, value); } Serialize(); }
void IEntitySecurity <GlobalPreference> .ValidateCreate(GlobalPreference value) { CheckAuthPrincipal(); }
void IEntitySecurity <GlobalPreference> .ValidateRead(GlobalPreference value, string expand) { CheckAuthPrincipal(); }