GetSystemDatabase() static private method

static private GetSystemDatabase ( ) : SQLite.SQLiteAsyncConnection
return SQLite.SQLiteAsyncConnection
Esempio n. 1
0
        private static async Task SetValueAsyncInternal(string name, string value, SQLiteAsyncConnection conn)
        {
            // if we don't have a connection, assume the system one...
            if (conn == null)
            {
                conn = StreetFooRuntime.GetSystemDatabase();
            }

            // load an existing value...
            var setting = await conn.Table <SettingItem>().Where(v => v.Name == name).FirstOrDefaultAsync();

            if (setting != null)
            {
                // change and update...
                setting.Value = value;
                await conn.UpdateAsync(setting);
            }
            else
            {
                setting = new SettingItem()
                {
                    Name  = name,
                    Value = value
                };

                // save...
                await conn.InsertAsync(setting);
            }
        }
        internal static async Task SetValueAsync(string name, string value)
        {
            var conn = StreetFooRuntime.GetSystemDatabase();

            // load an existing value...
            var setting = await conn.Table <SettingItem>().Where(v => v.Name == name).FirstOrDefaultAsync();

            if (setting != null)
            {
                // change and update...
                setting.Value = value;
                await conn.UpdateAsync(setting);
            }
            else
            {
                setting = new SettingItem()
                {
                    Name  = name,
                    Value = value
                };

                // save...
                await conn.InsertAsync(setting);
            }
        }
        internal static async Task <string> GetValueAsync(string name)
        {
            var conn = StreetFooRuntime.GetSystemDatabase();

            // load any existing value...
            var setting = (await conn.Table <SettingItem>().Where(v => v.Name == name).ToListAsync()).FirstOrDefault();

            if (setting != null)
            {
                return(setting.Value);
            }
            else
            {
                return(null);
            }
        }