示例#1
0
        public static Product EntityConvert(ProductDto dto)
        {
            Product p = new Product
            {
                Id          = dto.Id,
                Name        = dto.Name,
                UnitInStock = dto.UnitInStock,
                Price       = dto.Price,
                Vat         = dto.Vat,
                Category    = CategoryConversion.EntityConvert(dto.Category)
            };

            return(p);
        }
示例#2
0
        public static ProductDto Convert(Product p)
        {
            ProductDto dto = new ProductDto
            {
                Id          = p.Id,
                Name        = p.Name,
                UnitInStock = p.UnitInStock,
                Price       = p.Price,
                Vat         = p.Vat,
                Category    = CategoryConversion.Convert(p.Category)
            };

            return(dto);
        }
示例#3
0
        public static ICollection <ProductDto> ListConvert(List <Product> pList)
        {
            List <ProductDto> dtoList = new List <ProductDto>();

            foreach (Product p in pList)
            {
                ProductDto dto = new ProductDto
                {
                    Id          = p.Id,
                    Name        = p.Name,
                    UnitInStock = p.UnitInStock,
                    Price       = p.Price,
                    Vat         = p.Vat,
                    Category    = CategoryConversion.Convert(p.Category)
                };

                dtoList.Add(dto);
            }

            return(dtoList);
        }