Beispiel #1
0
        public async static Task SetAsync(PublicBicyclesContext db, string key, string value)
        {
            Config config = await db.Configs.FirstOrDefaultAsync(p => p.Key == key);

            if (config != null)
            {
                config.Value           = value;
                db.Entry(config).State = EntityState.Modified;
            }
            else
            {
                config = new Config()
                {
                    Key = key, Value = value
                };
                db.Configs.Add(config);
            }

            await db.SaveChangesAsync();
        }
Beispiel #2
0
        public async static Task <string> GetAsync(PublicBicyclesContext db, string key, string defaultValue)
        {
            string value = (await db.Configs.FirstOrDefaultAsync(p => p.Key == key))?.Value;

            return(value ?? defaultValue);
        }