예제 #1
0
        public async Task <ExternalServiceEntity> UpsertEntityAsync(ExternalServiceEntity entity)
        {
            var utcNow = DateTime.UtcNow;
            var query  = from item in _context.ExternalServices
                         where item.Name == entity.Name
                         select item;
            var result     = entity;
            var entityInDb = query.FirstOrDefault();

            if (entityInDb != null)
            {
                entityInDb.Updated = utcNow;
                _entityFrameworkMapperAccessor.MapperIgnoreBaseAndForeignTables.Map(entity, entityInDb);
                result = entityInDb;
            }
            else
            {
                entity.Id      = GuidS;
                entity.Created = utcNow;
                entity.Updated = utcNow;
                _context.ExternalServices.Add(entity);
            }
            await _context.SaveChangesAsync();

            return(result);
        }
        public IConsentDiscoveryCache GetConsentDiscoveryCache(ExternalServiceEntity externalServiceEntity)
        {
            IConsentDiscoveryCache value = null;

            if (!_map.TryGetValue(externalServiceEntity.Id, out value))
            {
                value = new ConsentDiscoveryCache(externalServiceEntity.Authority, () => _httpClientFactory.CreateClient());
                _map.TryAdd(externalServiceEntity.Id, value);
            }
            return(value);
        }