Пример #1
0
        public static DtoProducts Product_To_DtoProd(Products product)
        {
            DtoProducts DtoProd = new DtoProducts
            {
                _id      = product.productId,
                product  = product.productId,
                name     = product.name,
                image    = product.image,
                category = product.category,
                price    = product.price,
                brand    = product.brand,

                numRew       = product.numRew,
                countInStock = product.countInStock,
                description  = product.description
            };

            if (product.rating >= 1 && product.numRew >= 1)
            {
                DtoProd.rating = product.rating / product.numRew;
            }
            else
            {
                DtoProd.rating = 0;
            }



            return(DtoProd);
        }
Пример #2
0
        public static Products FromDtoProduct_To_Product(DtoProducts DtoProd)
        {
            var prod = new Products {
                productId    = DtoProd._id,
                name         = DtoProd.name,
                price        = DtoProd.price,
                image        = DtoProd.image,
                brand        = DtoProd.brand,
                category     = DtoProd.category,
                countInStock = DtoProd.countInStock,
                description  = DtoProd.description
            };

            return(prod);
        }