Example #1
0
        //Get a list of {Product Category View Model}
        public static List<ProductCategoryVM> GetProducts()
        {
            //Instance of productMapper
            ProductMapper _productMapper = new ProductMapper();
            //List of products
            var productList = _productMapper.GetProducts();
            //List of View model for Products
            var productVMList = new List<ProductCategoryVM>();

            foreach (var item in productList)
            {
                var prod = new ProductCategoryVM
                {
                    Id = item.Id,
                    Name = item.Name,
                    Description = item.Description,
                    Price = item.Price,
                    Category = _productMapper.GetProductCategory(item)
                };

                productVMList.Add(prod);
            }

            return productVMList;
        }