示例#1
0
        internal static async Task <SystemSettings> GetSystemSettings()
        {
            // TODO: Latest from DB not the cached in the server? If we are running on default, it will return null...
            var result = await Repository.GetLatestSystemSettingsAsync();

            return(DatabaseMapper.Map(result));
        }
        private async Task PostGpsLocation(GpsMeasurement gpsMeasurement)
        {
            try
            {
                // Send to CiaBatac
                await ciaBataController.PostGpsLocation(CiaBataMapper.ToGpsLocation(gpsMeasurement));

                // Save to database
                await Repository.InsertOrUpdateAsync(DatabaseMapper.Map(gpsMeasurement));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error posting gps");
            }
        }
示例#3
0
        public async Task LoadRadioSettingsFromDatabaseAsync()
        {
            try
            {
                var dbSettings = await DbContext.RadioSettings.ToListAsync(); // Execute query

                var radiosFromSettings = dbSettings
                                         .Select(rs => DatabaseMapper.Map(rs))
                                         .ToDictionary(r => r.RadioId, r => r);

                foreach (var radio in radiosFromSettings)
                {
                    radios.AddOrUpdate(radio.Key, radio.Value, (rid, oldvalue) => { return(radio.Value); });
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Could not load the radio settings from the database");
            }
        }