Exemple #1
0
        public async Task <User> GetUserInformationAsync(Guid userId)
        {
            if (userId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            IEnumerable <Models.Repository.Card> dtoCards;
            IEnumerable <Card> cards;
            IEnumerable <Models.Repository.Address> dtoAddresses;
            var dtoUser = await userRepository.GetAsync(userId);

            var user    = UserMapping.ConvertDtoUser(dtoUser);
            var cardIds = await userCardRepository.ListIdsAsync(dtoUser.UserId);

            var addressIds = await userAddressesRepository.ListIdsAsync(dtoUser.UserId);

            if (cardIds != null)
            {
                dtoCards = await cardRepository.ListAsync(cardIds);

                cards = await MapAddressesToCardsAsync(dtoCards);

                user.CreditCards = cards;
            }
            if (addressIds != null)
            {
                dtoAddresses = await addressRepository.ListAsync(addressIds);

                user.Address = AddressMapping.ConvertDtoAddressToAddress(dtoAddresses.FirstOrDefault());
            }

            return(user);
        }
        public async Task GetCardIdsByUserId()
        {
            await userCardRepository.AddAsync(userCard);

            var cardIds = await userCardRepository.ListIdsAsync(userCard.UserId);

            Assert.Equal(cardIds.FirstOrDefault(), userCard.CardId);
        }