public static PersistedGrant ToModel(this Entities.PersistedGrant token) { if (token == null) { return(null); } return(Mapper.Map <Entities.PersistedGrant, PersistedGrant>(token)); }
public void CanMap() { PersistedGrant model = new PersistedGrant(); Entities.PersistedGrant mappedEntity = model.ToEntity(); PersistedGrant mappedModel = mappedEntity.ToModel(); Assert.NotNull(mappedModel); Assert.NotNull(mappedEntity); }
public static void UpdateEntity(this PersistedGrant model, Entities.PersistedGrant entity) { entity.ClientId = model.ClientId; entity.ConsumedTime = model.ConsumedTime; entity.CreationTime = model.CreationTime; entity.Data = model.Data; entity.Description = model.Description; entity.Expiration = model.Expiration; entity.Key = model.Key; entity.SessionId = model.SessionId; entity.SubjectId = model.SubjectId; entity.Type = model.Type; }
public PersistedGrant Get(string key) { if (string.IsNullOrWhiteSpace(key)) { return(null); } Entities.PersistedGrant persistedGrant = null; using (var connection = _options.DbProviderFactory.CreateConnection()) { connection.ConnectionString = _options.ConnectionString; persistedGrant = connection.QueryFirstOrDefault <Entities.PersistedGrant>("select * from PersistedGrants where Key = @Key", new { Key = key }, commandTimeout: _options.CommandTimeOut, commandType: CommandType.Text); } return(persistedGrant?.ToModel()); }
public static PersistedGrant ToModel(this Entities.PersistedGrant entity) { return(entity is null ? null : new PersistedGrant { ClientId = entity.ClientId, ConsumedTime = entity.ConsumedTime, CreationTime = entity.CreationTime, Data = entity.Data, Description = entity.Description, Expiration = entity.Expiration, Key = entity.Key, SessionId = entity.SessionId, SubjectId = entity.SubjectId, Type = entity.Type }); }
public async Task StoreAsync(PersistedGrant grant) { DocumentSnapshot persistedGrant = await GetPersistedGrant(nameof(PersistedGrant.Key), grant.Key).ConfigureAwait(false); if (persistedGrant.Exists) { _logger.LogDebug("{persistedGrantKey} found in database", grant.Key); Entities.PersistedGrant existing = persistedGrant.ConvertTo <Entities.PersistedGrant>(); grant.UpdateEntity(existing); await persistedGrant.Reference.SetAsync(existing).ConfigureAwait(false); } else { _logger.LogDebug("{persistedGrant} not found in database", grant.Key); Entities.PersistedGrant persistedGrand = grant.ToEntity(); await _context.PersistedGrants.AddAsync(persistedGrand).ConfigureAwait(false); } }
/// <summary> /// Stores the asynchronous. /// </summary> /// <param name="token">The token.</param> /// <returns></returns> public Task StoreAsync(PersistedGrant token) { Entities.PersistedGrant existing = this._context.PersistedGrants .SingleOrDefault(x => x.Key == token.Key); if (existing == null) { this._logger.LogDebug( "{persistedGrantKey} not found in database", token.Key); var persistedGrant = token.ToEntity(); this._context.PersistedGrants.Add(persistedGrant); } else { this._logger.LogDebug( "{persistedGrantKey} found in database", token.Key); token.UpdateEntity(existing); } try { this._context.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { this._logger.LogWarning( "exception updating {persistedGrantKey} persisted grant in database: {error}", token.Key, ex.Message); } return(Task.FromResult(0)); }
async Task <Entities.PersistedGrant> GetEntityAsync(string key) { var table = await InitTable(); Entities.PersistedGrant model = null; var query = new TableQuery <Entities.PersistedGrant>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, WebUtility.UrlEncode(key))); TableContinuationToken continuationToken = null; do { var result = await table.ExecuteQuerySegmentedAsync(query, continuationToken); if (result.Results.Count > 0) { model = result.Results[0]; break; } continuationToken = result.ContinuationToken; } while (continuationToken != null); _logger.LogDebug("{persistedGrantKey} found in database: {persistedGrantKeyFound}", key, model != null); return(model); }
public static void UpdateEntity(this PersistedGrant token, Entities.PersistedGrant target) { Mapper.Map(token, target); }
public static PersistedGrant ToModel(this Entities.PersistedGrant token) { return(token == null ? null : Mapper.Map <PersistedGrant>(token)); }
/// <summary> /// Updates an entity from a model. /// </summary> /// <param name="model">The model.</param> /// <param name="entity">The entity.</param> public static void UpdateEntity(this PersistedGrant model, Entities.PersistedGrant entity) { Mapper.Map(model, entity); }
/// <summary> /// Maps an entity to a model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static PersistedGrant ToModel(this Entities.PersistedGrant entity) { return(entity == null ? null : Mapper.Map <PersistedGrant>(entity)); }
private void SetTokenExpirationInDocumentMetadata(IAsyncDocumentSession session, Entities.PersistedGrant persistedGrant) { session.Advanced.GetMetadataFor(persistedGrant)[Constants.Documents.Metadata.Expires] = persistedGrant.Expiration; }