Beispiel #1
0
        public ActionResult <CreatePileResponse> CreatePile(string deckHash)
        {
            var deck = _deckRepository.GetDeck(deckHash);
            var pile = new Pile {
                Hash = _hashids.Encode(deck.Piles.Count)
            };

            deck.Piles.Add(pile);
            _deckRepository.Update(deck);
            return(Ok(_mapper.Map <CreatePileResponse>(pile)));
        }
Beispiel #2
0
        public Pile Generate(string hash)
        {
            var deck = _deckRepository.GetDeck(hash);
            var pile = new Pile {
                Hash = _hashids.Encode(deck.Piles.Count)
            };

            deck.Piles.Add(pile);
            _deckRepository.Update(deck);
            return(pile);
        }
Beispiel #3
0
        private string ComputeShortLink(int urlId)
        {
            var hash    = _hashids.Encode(urlId);
            var baseUrl = _configuration.GetValue <string>("SLINK_BASE_URL");

            if (Uri.TryCreate(new Uri(baseUrl), hash, out var finalUrl))
            {
                return(finalUrl.ToString());
            }

            return(null);
        }
        public async Task ReturnNewlyCreatedCharacterId()
        {
            mediator.Send(Arg.Any <CreateRpgCharacterRequest>()).Returns(new CreateRpgCharacterResponse(NumericId));
            hashids.Encode(NumericId).Returns(StringId);

            var actionResult = await controller.Post();

            await mediator.Received().Send(Arg.Any <CreateRpgCharacterRequest>());

            hashids.Received().Encode(NumericId);
            actionResult.Result.Should().BeOfType <OkObjectResult>();
            var correctResult = actionResult.Result as OkObjectResult;

            correctResult?.Value.Should().Be(StringId);
        }
Beispiel #5
0
 public void Insert(Deck deck)
 {
     deck.Hash = _hashids.Encode(deck.Id);
     db.GetCollection <Deck>().Insert(deck);
 }
Beispiel #6
0
 /// <summary>
 /// Gets the hash key for the single identifier value.
 /// </summary>
 /// <param name="id">The identifier to be encoded as a hashed key.</param>
 /// <returns>A string containing the hashed key that represents the identifier.</returns>
 public string GetHash(int id)
 {
     return(_hasher.Encode(id));
 }
Beispiel #7
0
 private string ToPublicId(int characterId) => hashids.Encode(characterId);