public async Task <User> GetAsync(OpenIdKey openIdKey) { var db = _connectionMultiplexer.GetDatabase(); var user = await db.JsonGetAsync <User>(openIdKey.GetPersistenceKey()); if (string.IsNullOrWhiteSpace(user.FullName)) { user.FirstName = user.Email; } return(user); }
public async Task <User> UpdateAsync(OpenIdKey openIdKey, UpdateUserInfo userInfo) { var db = _connectionMultiplexer.GetDatabase(); var user = await db.JsonGetAsync <User>(openIdKey.GetPersistenceKey()); user.Update(userInfo); var json = JsonSerializer.Serialize(user, _jsonSerializerOptions); var persistenceResult = await db.JsonSetAsync(user.GetPersistenceKey(), json); _logger.LogDebug("[User] [UPDATE] {json} [{result}]", json, persistenceResult.IsSuccess); return(user); }
public async Task <bool> UpdateRequestStatus(Guid id, OpenIdKey openIdKey, DetailedStatusList status) { var db = _connectionMultiplexer.GetDatabase(); await db.JsonSetAsync(RedisConstants.GetBloodRequestPersistenceKey(id), JsonSerializer.Serialize(status, _jsonSerializerOptions), ".Status"); var path = status switch { DetailedStatusList.Assigned => ".AssignedBy", DetailedStatusList.Cancelled => ".CancelledBy", _ => ".ActionBy", }; var result = await db.JsonSetAsync(RedisConstants.GetBloodRequestPersistenceKey(id), JsonSerializer.Serialize(openIdKey.GetPersistenceKey(), _jsonSerializerOptions), path); return(result.IsSuccess); }
public async Task <int> DeleteAsync(OpenIdKey openIdKey) { var db = _connectionMultiplexer.GetDatabase(); return(await db.JsonDeleteAsync(openIdKey.GetPersistenceKey())); }