Example #1
0
        public async Task <WishlistViewDto> GetAllWishlistItemsAsync(string wishlistOwnerId, string currentUserId, string whanauId)
        {
            try
            {
                var wishlistOwner = await _whanauRepository.GetPersonAsync(wishlistOwnerId, whanauId);

                var wishlistItems = await _wishlistRepository.GetAllWishlistItemsAsync(wishlistOwnerId);

                var requesterIsOwner = wishlistOwnerId == currentUserId;

                var dtos = wishlistItems.Select(w =>
                                                new WishlistItemDto
                {
                    Id            = w.Id,
                    UserId        = w.UserId,
                    Description   = w.Description,
                    IsClaimable   = string.IsNullOrEmpty(w.ClaimedByUserId) && !requesterIsOwner,
                    IsClaimedByMe = w.ClaimedByUserId == currentUserId && !requesterIsOwner
                });

                return(new WishlistViewDto(wishlistOwner.Name, requesterIsOwner, dtos));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception while getting wishlist items.");
                throw;
            }
        }