コード例 #1
0
        // Check to see if there are any new eps and adds it to db
        public void CheckPlayerLog()
        {
            var newEpisodes = LogParserV2.GetEpisodesFromLog();

            if (newEpisodes == null)
            {
                return;
            }
            foreach (var newEpisode in newEpisodes)
            {
                //check timestamps against db to determine if it is actually a new episode
                if (_episodeRepository.EpisodeExists(newEpisode.Timestamp))
                {
                    continue;
                }

                //convert entity to model
                var episodeModel = new EpisodeModel
                {
                    Crowns          = newEpisode.Crowns,
                    Fame            = newEpisode.Fame,
                    Kudos           = newEpisode.Kudos,
                    Timestamp       = newEpisode.Timestamp,
                    Season          = 1,
                    EpisodeFinished = newEpisode.EpisodeFinished,
                    Created         = DateTime.UtcNow
                };

                var id = _episodeRepository.AddEpisode(episodeModel);

                //add round models to db
                var rounds = new List <RoundModel>();
                foreach (var round in newEpisode.RoundEntities)
                {
                    var roundModel = new RoundModel()
                    {
                        Kudos      = round.Kudos,
                        Fame       = round.Fame,
                        RoundType  = round.RoundType,
                        Badge      = round.Badge,
                        BonusFame  = round.BonusFame,
                        BonusKudos = round.BonusKudos,
                        BonusTier  = round.BonusTier,
                        EpisodeId  = id,
                        Position   = round.Position,
                        Qualified  = round.Qualified
                    };
                    rounds.Add(roundModel);
                }
                _episodeRepository.AddRounds(rounds);
                _logger.LogInformation($"Saved {newEpisode.Timestamp} to db");
            }
        }
コード例 #2
0
ファイル: EpisodeService.cs プロジェクト: NRKirby/DevPodcasts
 public bool EpisodeExists(int episodeId)
 {
     return(_episodeRepository.EpisodeExists(episodeId));
 }