Beispiel #1
0
        public IList <FavoriteBookInfoContract> GetFavoriteLabeledBooks(IList <long> bookIds)
        {
            if (bookIds == null)
            {
                bookIds = new List <long>();
            }
            var user     = TryGetUser();
            var dbResult = m_favoritesRepository.GetFavoriteLabeledBooks(bookIds, user.Id);

            var resultList = new List <FavoriteBookInfoContract>();

            foreach (var favoriteBookGroup in dbResult.GroupBy(x => x.Book.Id))
            {
                var favoriteItems = new FavoriteBookInfoContract
                {
                    Id           = favoriteBookGroup.Key,
                    FavoriteInfo = favoriteBookGroup.Select(Mapper.Map <FavoriteBaseDetailContract>).ToList()
                };
                resultList.Add(favoriteItems);
            }
            return(resultList);
        }