コード例 #1
0
        public IEnumerable <CollectionDTO> GetCollection()
        {
            List <CollectionDTO> dtos = new List <CollectionDTO>();

            foreach (Collection collec in collectionRepository.FindAll())
            {
                CollectionDTO cdto = new CollectionDTO();
                cdto.CollectionId       = collec.CollectionId;
                cdto.collectionName     = collec.collectionName;
                cdto.aestheticParameter = collec.aestheticParameter;
                cdto.products           = new List <ProductDTO>();

                foreach (CollectionProduct cp in collec.CollectionProducts)
                {
                    ProductDTO productDTO = productToDTO(cp.Product);
                    cdto.products.Add(productDTO);
                }

                dtos.Add(cdto);
            }

            return(dtos);
        }