public void SaveAccessToken(AccessToken token) { AccessTokenRow existing = null; if (token.Id != 0) { existing = AccessTokens.FirstOrDefault(x => x.AccessTokenRowId == token.Id); } if (existing != null) { existing.ExpirationDate = token.ExpirationDate; return; } var newAccessTokenRowId = AccessTokens.Count == 0 ? 1 : AccessTokens.Max(t => t.AccessTokenRowId) + 1; AccessTokens.Add(new AccessTokenRow { AccessTokenRowId = newAccessTokenRowId, Value = token.Value, UserId = token.UserId, ContentId = token.ContentId == 0 ? (int?)null : token.ContentId, Feature = token.Feature, CreationDate = token.CreationDate, ExpirationDate = token.ExpirationDate }); token.Id = newAccessTokenRowId; }
private AccessToken CreateAccessTokenFromRow(AccessTokenRow row) { return(new AccessToken { Id = row.AccessTokenRowId, Value = row.Value, UserId = row.UserId, ContentId = row.ContentId ?? 0, Feature = row.Feature, CreationDate = row.CreationDate, ExpirationDate = row.ExpirationDate }); }