Exemple #1
0
        public async Task <List <BookshelfForDisplayDto> > AllByUserId(int id)
        {
            var bookshelves = await _bookshelfRepository.AllByUserId(id);

            var bookshelvesDto = new List <BookshelfForDisplayDto>(); // can use auto mapper for that

            foreach (var bookshelf in bookshelves)
            {
                bookshelvesDto.Add(new BookshelfForDisplayDto {
                    Id          = bookshelf.Id,
                    userId      = bookshelf.UserId, // why is userId lowercase?
                    Name        = bookshelf.Name,
                    Description = bookshelf.Description,
                    IsPublic    = bookshelf.IsPublic
                });
            }
            return(bookshelvesDto);
        }