Esempio n. 1
0
        public static externalDTO.Product MapFromDAL(internalDTO.Product product)
        {
            var res = product == null ? null : new externalDTO.Product
            {
                Id = product.Id,
                ManuFacturerItemCode      = product.ManuFacturerItemCode,
                ShopCode                  = product.ShopCode,
                ProductName               = product.ProductName,
                BuyPrice                  = product.BuyPrice,
                PercentageAddedToBuyPrice = product.PercentageAddedToBuyPrice,
                SellPrice                 = product.SellPrice,
                Quantity                  = product.Quantity,
                Weight = product.Weight,
                Length = product.Length,
            };

            if (product?.Manufacturer != null)
            {
                res.ManuFacturerId = product.ManuFacturerId;
                res.Manufacturer   = ManuFacturerMapper.MapFromDAL(product.Manufacturer);
                res.InventoryId    = product.InventoryId;
                res.Inventory      = InventoryMapper.MapFromDAL(product.Inventory);
                res.ShopId         = product.ShopId;
                res.Shop           = ShopMapper.MapFromDAL(product.Shop);
            }

            if (product?.Comments != null)
            {
                res.Comments = product.Comments.Select(e => new BLL.App.DTO.DomainLikeDTO.Comment()
                {
                    CommentTitle = e.CommentTitle,
                    CommentBody  = e.CommentBody,
                    Id           = e.Id
                }).ToList();
            }

            return(res);
        }
Esempio n. 2
0
        public static internalDTO.Product MapFromBLL(externalDTO.Product product)
        {
            var res = product == null ? null : new internalDTO.Product
            {
                Id = product.Id,
                ManuFacturerItemCode      = product.ManuFacturerItemCode,
                ShopCode                  = product.ShopCode,
                ProductName               = product.ProductName,
                BuyPrice                  = product.BuyPrice,
                PercentageAddedToBuyPrice = product.PercentageAddedToBuyPrice,
                SellPrice                 = product.SellPrice,
                Quantity                  = product.Quantity,
                Weight         = product.Weight,
                Length         = product.Length,
                ManuFacturerId = product.ManuFacturerId,
                Manufacturer   = ManuFacturerMapper.MapFromBLL(product.Manufacturer),
                InventoryId    = product.InventoryId,
                Inventory      = InventoryMapper.MapFromBLL(product.Inventory),
                ShopId         = product.ShopId,
                Shop           = ShopMapper.MapFromBLL(product.Shop)
            };

            return(res);
        }