Exemple #1
0
        public async Task LikeCurrentAudio(ulong guildId, ulong userId, LikeType likeType)
        {
            var playerBag = GetPlayerBag(guildId);

            var ar = new AudioRating
            {
                AudioIdentifier = playerBag.Player.CurrentTrack.Identifier,
                GuildId         = guildId,
                UserId          = userId,
                LikeType        = likeType
            };

            await _audioRatingRepository.SetAudioRating(ar);

            UpdatePlayerView(guildId);
        }
Exemple #2
0
        public async Task <AudioRating> SetAudioRating(AudioRating audioRating)
        {
            if (audioRating is null)
            {
                return(null);
            }

            await _konekoContext.AudioRatings
            .Upsert(audioRating)
            .On(k => new { k.AudioIdentifier, k.GuildId, k.UserId })
            .WhenMatched(k => new AudioRating
            {
                LikeType = k.LikeType == audioRating.LikeType ? LikeType.None : audioRating.LikeType
            }).RunAsync();

            await _konekoContext.SaveChangesAsync();

            return(audioRating);
        }