예제 #1
0
        public async Task <WishlistModel> Map(Wishlist wishlist)
        {
            var userWishlists = await userRepo.GetUsers(wishlist.GetPeople().Select(s => s.PersonId).ToArray());

            return(new WishlistModel()
            {
                Id = wishlist.Id,
                Name = wishlist.Name,
                People = wishlist.GetPeople().Select(s =>
                                                     new WishlistPersonModel()
                {
                    PersonId = s.PersonId,
                    Giftee = s.Giftee,
                    Name = userWishlists.Single(g => g.Id == s.PersonId).Name,
                    Email = userWishlists.Single(g => g.Id == s.PersonId).Email,
                    PresentIdeas = s.PresentIdeas
                                   .Select(t => new PresentIdeaModel()
                    {
                        Id = t.Id,
                        Description = t.Description,
                        ClaimerId = t.ClaimerId.HasValue == false ?
                                    null :
                                    t.ClaimerId,
                        ClaimerName =
                            t.ClaimerId.HasValue == false ?
                            null :
                            userWishlists.Single(g => g.Id == t.ClaimerId).Name,
                        ClaimerEmail =
                            t.ClaimerId.HasValue == false ?
                            null :
                            userWishlists.Single(g => g.Id == t.ClaimerId).Email
                    }).ToList()
                }).ToList()
            });
        }