Exemple #1
0
        public async Task InsertTwitchMonitorRecord(TwitchMonitorRecord twitchMonitorRecord)
        {
            try
            {
                await _collection.InsertOneAsync(twitchMonitorRecord);

                //Log.Information($"Twitch Monitor Record with username {twitchMonitorRecord.twitchUsername} saved successfully");
            }
            catch (Exception e)
            {
                //Log.Error($"Twitch Monitor Record with username {twitchMonitorRecord.twitchUsername} failed saving for reason: {e.Message}");
            }
        }
Exemple #2
0
        public async Task UpdateTwitchMonitorRecord(TwitchMonitorRecord twitchMonitorRecord)
        {
            var filterOne = Builders <TwitchMonitorRecord> .Filter.Eq("twitchMonitorRecordId", twitchMonitorRecord.twitchMonitorRecordId);

            try
            {
                await _collection.ReplaceOneAsync(filterOne, twitchMonitorRecord);

                // Log.Information($"Twitch Monitor Record with username {twitchMonitorRecord.twitchUsername} saved successfully");
            }
            catch (Exception e)
            {
                // Log.Error($"Twitch Monitor Record with username {twitchMonitorRecord.twitchUsername} failed saving for reason: {e.Message}");
            }
        }
Exemple #3
0
        public async Task <List <TwitchMonitorRecord> > GetTwitchMonitorRecord(TwitchMonitorRecord twitchMonitorRecord)
        {
            try
            {
                var filterOne = Builders <TwitchMonitorRecord> .Filter.Eq("twitchMonitorRecordId", twitchMonitorRecord.twitchMonitorRecordId);

                var results = await _collection.FindAsync <TwitchMonitorRecord>(filterOne);

                return(await results.ToListAsync());
            }
            catch (Exception e)
            {
                // Log.Error($"Twitch Monitor Record with username {twitchMonitorRecord.twitchUsername} failed fetching for reason: {e.Message}");
                return(null);
            }
        }
Exemple #4
0
        public async Task SaveOrUpdateTwitchMonitorRecord(TwitchMonitorRecord record)
        {
            var twitchMonitorSettingsList = await twitchSettingsRepo.GetTwitchMonitorRecord(record);

            if (twitchMonitorSettingsList == null)
            {
                return;
            }
            switch (twitchMonitorSettingsList.Count)
            {
            case 0:
                await twitchSettingsRepo.InsertTwitchMonitorRecord(record);

                break;

            default:
                await twitchSettingsRepo.UpdateTwitchMonitorRecord(record);

                break;
            }
            await TwitchMonitor.UpdateMonitorList();
        }