コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public AcceptBloodDonationRequest(Guid requestId, OpenIdKey openIdKey)
 {
     RequestId = requestId;
     OpenIdKey = openIdKey;
 }
コード例 #6
0
 public CancelBloodDonationRequest(Guid requestId, OpenIdKey cancelledBy)
 {
     RequestId   = requestId;
     CancelledBy = cancelledBy;
 }
コード例 #7
0
        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)));
        }
コード例 #8
0
        public async Task <int> DeleteAsync(OpenIdKey openIdKey)
        {
            var db = _connectionMultiplexer.GetDatabase();

            return(await db.JsonDeleteAsync(openIdKey.GetPersistenceKey()));
        }