示例#1
0
        public void ClearExpiredClaimsAync()
        {
            List <Claim> claims = _database.GetAllExpiredClaims();

            if (claims.Count == 0)
            {
                return;
            }
            _logger.LogError($"Clearing all these expired claims:\n{ObjectLogger.Dump(claims)}");
            _database.ClearAllExpiredClaims();
        }
示例#2
0
 public async Task CreateRefreshTokenAsync(TokenExtended token)
 {
     _logger.LogDebug($"Creating token for TokenExtended Object: {ObjectLogger.Dump(token)}");
     _logger.LogInformation($"Creating token for refresh token: {token.RefreshToken}");
     using (var connection = _context.CreateConnection())
     {
         var    parameters   = new { value = token.RefreshToken, created_at = token.CreatedAt, id_users = token.UserId };
         string processQuery = "INSERT INTO token (value,created_at,id_users) VALUES (@value,@created_at,@id_users)";
         await connection.ExecuteAsync(processQuery, parameters);
     }
 }
示例#3
0
 public async Task InsertPeopleInEpisodeAsync(List <PeopleInEpisode> people, int episodeId)
 {
     _logger.LogInformation($"Inserting people into episode with id: {episodeId}");
     _logger.LogDebug($"Inserting people: {ObjectLogger.Dump(people)}");
     foreach (PeopleInEpisode person in people)
     {
         using (var connection = _context.CreateConnection())
         {
             var    parameters   = new { created_at = DateTime.Now, id_person = person.PersonId, id_episodes = episodeId };
             string processQuery = "INSERT INTO episode_person (created_at,id_person,id_episodes) VALUES (@created_at,@id_person,@id_episodes);";
             await connection.ExecuteAsync(processQuery, parameters);
         }
     }
 }
示例#4
0
 public void AddEpisodes(List <Episode> episodes)
 {
     using (var connection = _context.CreateConnection())
     {
         foreach (Episode item in episodes)
         {
             _logger.LogDebug($"Adding new episode: {ObjectLogger.Dump(item)}");
             _logger.LogInformation($"Adding new episode with EpisodeNumber: {item.EpisodeNumber}");
             var    parameters   = new { uuid = item.UUID, title = item.Title, episode_number = item.EpisodeNumber, subtitle = item.Subtitle, description = item.Description, media_file = item.MediaFile, spotify_file = item.SpotifyFile, duration = item.Duration, type = item.Type, image = item.Image, explicitItem = item.Explicit, published_at = item.PublishedAt, created_at = item.CreatedAt, updated_at = item.UpdatedAt, verified = item.Verified };
             string processQuery = "INSERT INTO episodes (uuid,title,episode_number,subtitle,description,media_file,spotify_file,duration,type,image,explicit,published_at,created_at,updated_at,verified) VALUES (@uuid,@title,@episode_number,@subtitle,@description,@media_file,@spotify_file,@duration,@type,@image,@explicitItem,@published_at,@created_at,@updated_at,@verified)";
             connection.Execute(processQuery, parameters);
         }
     }
 }
示例#5
0
        public async Task InsertTopicAsync(ProcessedTopicPostRequest topic, int episodeId, int userId)
        {
            _logger.LogDebug($"Topic contributed by user with id: {userId} in episode with id: {episodeId} to insert: {ObjectLogger.Dump(topic)}");
            _logger.LogInformation($"Inserting list of topics.");
            var parameters = new
            {
                name                  = topic.Name,
                timestamp_start       = topic.TimestampStart,
                timestamp_end         = topic.TimestampEnd,
                duration              = topic.Duration,
                community_contributed = topic.CommunityContributed,
                ad         = topic.Ad,
                created_at = DateTime.Now,
                epId       = episodeId,
                uId        = userId
            };

            using (var connection = _context.CreateConnection())
            {
                string processQuery = "INSERT INTO topic (name,timestamp_start,timestamp_end,duration,community_contributed,ad,created_at,id_episodes,id_user) " +
                                      "VALUES (@name,@timestamp_start,@timestamp_end,@duration,@community_contributed,@ad,@created_at,@epId,@uId); SELECT * FROM LASTVAL();";
                int topicId = await connection.ExecuteScalarAsync <int>(processQuery, parameters);

                for (int i = 0; i < topic.Subtopics.Count; i++)
                {
                    await InsertSubtopicAsync(topic.Subtopics[i], topicId, userId);
                }
            }
        }