public async Task <CharacterLocationDto> Handle(MoveCharacterCommand request, CancellationToken cancellationToken)
        {
            var characterLocation = await _characterLocationRepository.GetByCharacterIdAsync(request.CharacterId, cancellationToken);

            if (characterLocation != null)
            {
                characterLocation.ChangeLocation(request.X, request.Y);
            }
            else
            {
                characterLocation = CharacterLocation.Create(request.CharacterId,
                                                             request.X, request.Y, _singleLocationPerCharacterChecker);
                await _characterLocationRepository.AddAsync(characterLocation, cancellationToken);
            }

            await _unitOfWork.CommitAsync(cancellationToken);

            return(CharacterLocationDto.FromCharacterLocation(characterLocation));
        }
Exemple #2
0
 public async Task <bool> CharacterHasNoLocationAsync(Guid characterId)
 {
     return(await _characterLocationRepository.GetByCharacterIdAsync(characterId) == null);
 }
Exemple #3
0
        public async Task <CharacterLocationDto> Handle(GetCharacterLocationQuery request, CancellationToken cancellationToken)
        {
            var characterLocation = await _characterLocationRepository.GetByCharacterIdAsync(request.CharacterId, cancellationToken);

            return(characterLocation == null ? null : CharacterLocationDto.FromCharacterLocation(characterLocation));
        }