Beispiel #1
0
        public async Task <Unit> Handle(StartNewAdventureCommand command, CancellationToken ct)
        {
            var adventure = await _adventureRepository.GetAsync(command.AdventureId);

            var session = new UserAdventureSession(command.UserId, adventure);

            await _userAdventureSessionRepository.SaveAsync(session);

            return(Unit.Value);
        }
        public async Task SaveAsync(UserAdventureSession userAdventureSession)
        {
            var userId      = userAdventureSession.UserId;
            var adventureId = userAdventureSession.AdventureId;

            var key = GetKey(userId, adventureId);

            var bytes = JsonSerializer.SerializeToUtf8Bytes(userAdventureSession);

            await _redis.HashSetAsync(RedisHashKey, key, bytes);
        }