public async Task AddOrUpdateAsync(UrlReferrer urlReferrer)
        {
            await _dbContext.UrlReferrers.InsertOrUpdateAsync(
                () => new UrlReferrerDb
            {
                ChannelId = urlReferrer.ChannelId,
                Host      = urlReferrer.Host,
                IsDeleted = false
            },
                dbValue => new UrlReferrerDb
            {
                IsDeleted = false,
                ChannelId = urlReferrer.ChannelId ?? dbValue.ChannelId
            },
                () => new UrlReferrerDb
            {
                Host = urlReferrer.Host
            }
                );

            _distributedCache.Delete(WhiteListCacheKey);
        }
Esempio n. 2
0
        public async Task <bool> UpdateAsync(Channel channel)
        {
            if (channel.Id == 0)
            {
                throw new ArgumentException(nameof(channel.Id));
            }

            var channelDb = _mapper.Map <ChannelDb>(channel);

            var result = await _dbContext.UpdateAsync(channelDb);

            var updated = result == 1;

            if (updated)
            {
                _distributedCache.Delete(GetChannelIdKey(channel.Id));
            }

            return(updated);
        }