Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 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}]");
     }
 }
Ejemplo n.º 3
0
 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}]");
     }
 }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------------------
        /// <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));
        }
Ejemplo n.º 5
0
        public IHttpActionResult GetGlobalPreference(int id)
        {
            GlobalPreference globalPreference = db.GlobalPreferences.Find(id);

            if (globalPreference == null)
            {
                return(NotFound());
            }

            return(Ok(globalPreference));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        //------------------------------------------------------------------------------------
        /// <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();
        }
Ejemplo n.º 8
0
 void IEntitySecurity <GlobalPreference> .ValidateCreate(GlobalPreference value)
 {
     CheckAuthPrincipal();
 }
Ejemplo n.º 9
0
 void IEntitySecurity <GlobalPreference> .ValidateRead(GlobalPreference value, string expand)
 {
     CheckAuthPrincipal();
 }