public IEnumerable <ProductDTO> GetShopProducts(int shopId)
        {
            IEnumerable <ProductDTO> shopProducts =
                MappingUtil.MapCollection <Product, ProductDTO>(dataset.Products.GetByShop(shopId));

            return(shopProducts);
        }
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            IEnumerable <ShopDTO> shopDtos = shopService.GetShops();
            IEnumerable <Shop>    shops    = MappingUtil.MapCollection <ShopDTO, Shop>(shopDtos);

            return(Ok(shops));
        }
        // GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            ShopDTO shopDto = shopService.GetShop(id);

            if (shopDto == null)
            {
                return(NotFound());
            }

            IEnumerable <ProductDTO> shopProductDtos = productService.GetShopProducts(id);
            ShopProducts             shopProducts    = new ShopProducts()
            {
                Shop     = MappingUtil.MapInstance <ShopDTO, Shop>(shopDto),
                Products = MappingUtil.MapCollection <ProductDTO, Product>(shopProductDtos)
            };

            return(Ok(shopProducts));
        }
Esempio n. 4
0
        public IEnumerable <ShopDTO> GetShops()
        {
            IEnumerable <ShopDTO> shops = MappingUtil.MapCollection <Shop, ShopDTO>(dataset.Shops.GetAll());

            return(shops);
        }