Exemple #1
0
 public static ProductShort ConvertToShortDTO(this BB.Core.Model.Product entity)
 {
     return(new ProductShort()
     {
         ProductId = entity.ProductId,
         Price = entity.Price,
         Name = entity.Name,
         ImageURL = entity.FacingImage == null ? entity.ProductCategory.FacingImage.PictureUrl : entity.FacingImage.PictureUrl
     });
 }
Exemple #2
0
        public static Product ConvertToDTO(this BB.Core.Model.Product entity)
        {
            var result = new Product();

            result.ProductId       = entity.ProductId;
            result.Price           = entity.Price;
            result.Name            = entity.Name;
            result.ImageURL        = entity.FacingImage == null ? entity.ProductCategory.FacingImage.PictureUrl : entity.FacingImage.PictureUrl;
            result.ProductCategory = entity.ProductCategory.ConvertToShortDTO();
            result.ProductDetails  = entity.ProductDetails?.ConvertToDTO();

            foreach (var it in entity.ProductPictures)
            {
                result.Images.Add(it.PictureUrl);
            }

            foreach (var it in entity.ProductCharacteristics)
            {
                result.ProductCharacteristics.Add(it.ConvertToDTO());
            }

            return(result);
        }