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 static BloodRequest Create(CreateBloodRequest dto, OpenIdKey openIdKey) { var result = new BloodRequest { OpenIdKey = openIdKey, BloodGroup = dto.BloodGroup, DonationType = dto.DonationType, PatientName = dto.PatientName, Priority = dto.Priority, QuantityInUnits = dto.QuantityInUnits, Reason = dto.Reason, Status = DetailedStatusList.Open, Id = Guid.NewGuid() }; return(result); }
public AcceptBloodDonationRequest(Guid requestId, OpenIdKey openIdKey) { RequestId = requestId; OpenIdKey = openIdKey; }
public CancelBloodDonationRequest(Guid requestId, OpenIdKey cancelledBy) { RequestId = requestId; CancelledBy = cancelledBy; }
public static Result <OpenIdKey> GetOpenIdKey(this ClaimsPrincipal claimsPrincipal) { var nameIdentifier = claimsPrincipal.Claims.FirstOrDefault(q => q.Type.Equals(ClaimTypes.NameIdentifier, StringComparison.OrdinalIgnoreCase))?.Value ?? string.Empty; return(string.IsNullOrWhiteSpace(nameIdentifier) ? Result <OpenIdKey> .Error("Claim missing") : Result <OpenIdKey> .Success(OpenIdKey.Create(nameIdentifier))); }
public async Task <int> DeleteAsync(OpenIdKey openIdKey) { var db = _connectionMultiplexer.GetDatabase(); return(await db.JsonDeleteAsync(openIdKey.GetPersistenceKey())); }