public static webModel.ProductAssociation ToWebModel(this moduleModel.ProductAssociation association, IBlobUrlResolver blobUrlResolver)
        {
            var retVal = new webModel.ProductAssociation();

            retVal.InjectFrom(association);
            retVal.Tags = association.Tags;
            if (association.AssociatedObject != null)
            {
                var product  = association.AssociatedObject as moduleModel.CatalogProduct;
                var category = association.AssociatedObject as moduleModel.Category;
                if (product != null)
                {
                    var associatedProduct = product.ToWebModel(blobUrlResolver);
                    retVal.AssociatedObjectImg  = associatedProduct.ImgSrc;
                    retVal.AssociatedObjectName = associatedProduct.Name;
                }
                if (category != null)
                {
                    var associatedCategory = category.ToWebModel(blobUrlResolver);
                    retVal.AssociatedObjectImg  = associatedCategory.ImgSrc;
                    retVal.AssociatedObjectName = associatedCategory.Name;
                }
            }

            return(retVal);
        }
Пример #2
0
        public void AssociationTest()
        {
            //Get all product associations
            var productController = new CatalogModuleProductsController(GetItemService(), GetPropertyService(), null, null, null);
            var productResult     = productController.Get("v-b004y45rxi") as OkNegotiatedContentResult <webModel.Product>;
            var product           = productResult.Content;

            Assert.IsFalse(product.Associations.Any());


            //Add association
            var association = new webModel.ProductAssociation
            {
                ProductId = "v-b0007zl6ds",
                Name      = "Related Items"
            };

            product.Associations.Add(association);
            productController.Update(product);


            //Remove
            product.Associations.Remove(product.Associations.Last());
            productController.Update(product);
        }
        public static webModel.ProductAssociation ToWebModel(this moduleModel.ProductAssociation association, IBlobUrlResolver blobUrlResolver)
        {
            var retVal = new webModel.ProductAssociation();

            //Do not use omu.InjectFrom for performance reasons

            retVal.AssociatedObjectId   = association.AssociatedObjectId;
            retVal.AssociatedObjectType = association.AssociatedObjectType;
            retVal.Quantity             = association.Quantity;
            retVal.Tags     = association.Tags;
            retVal.Type     = association.Type;
            retVal.Priority = association.Priority;
            retVal.Tags     = association.Tags;

            if (association.AssociatedObject != null)
            {
                var product  = association.AssociatedObject as moduleModel.CatalogProduct;
                var category = association.AssociatedObject as moduleModel.Category;
                if (product != null)
                {
                    var associatedProduct = product.ToWebModel(blobUrlResolver);
                    retVal.AssociatedObjectImg  = associatedProduct.ImgSrc;
                    retVal.AssociatedObjectName = associatedProduct.Name;
                }
                if (category != null)
                {
                    var associatedCategory = category.ToWebModel(blobUrlResolver);
                    retVal.AssociatedObjectImg  = associatedCategory.ImgSrc;
                    retVal.AssociatedObjectName = associatedCategory.Name;
                }
            }

            return(retVal);
        }
        public static moduleModel.ProductAssociation ToCoreModel(this webModel.ProductAssociation association)
        {
            var retVal = new moduleModel.ProductAssociation();

            retVal.InjectFrom(association);
            retVal.Tags = association.Tags;
            return(retVal);
        }
        public static moduleModel.ProductAssociation ToModuleModel(this webModel.ProductAssociation association)
        {
            var retVal = new moduleModel.ProductAssociation();

            retVal.InjectFrom(association);
            retVal.AssociatedProductId = association.ProductId;
            return(retVal);
        }
 public static webModel.ProductAssociation ToWebModel(this moduleModel.ProductAssociation association, IBlobUrlResolver blobUrlResolver)
 {
     var retVal = new webModel.ProductAssociation();
     retVal.InjectFrom(association);
     if (association.AssociatedProduct != null)
     {
         var associatedProduct = association.AssociatedProduct.ToWebModel(blobUrlResolver);
         retVal.ProductId = associatedProduct.Id;
         retVal.ProductCode = associatedProduct.Code;
         retVal.ProductImg = associatedProduct.ImgSrc;
         retVal.ProductName = associatedProduct.Name;
     }
     return retVal;
 }
        public static webModel.ProductAssociation ToWebModel(this moduleModel.ProductAssociation association, IBlobUrlResolver blobUrlResolver)
        {
            var retVal = new webModel.ProductAssociation();

            retVal.InjectFrom(association);
            if (association.AssociatedProduct != null)
            {
                var associatedProduct = association.AssociatedProduct.ToWebModel(blobUrlResolver);
                retVal.ProductId   = associatedProduct.Id;
                retVal.ProductCode = associatedProduct.Code;
                retVal.ProductImg  = associatedProduct.ImgSrc;
                retVal.ProductName = associatedProduct.Name;
            }
            return(retVal);
        }
        public void AssociationTest()
        {
            //Get all product associations
            var productController = new CatalogModuleProductsController(GetItemService(), GetPropertyService(), null, null, null);
            var productResult = productController.Get("v-b004y45rxi") as OkNegotiatedContentResult<webModel.Product>;
            var product = productResult.Content;
            Assert.IsFalse(product.Associations.Any());


            //Add association
            var association = new webModel.ProductAssociation
            {
                ProductId = "v-b0007zl6ds",
                Name = "Related Items"
            };
            product.Associations.Add(association);
            productController.Update(product);


            //Remove
            product.Associations.Remove(product.Associations.Last());
            productController.Update(product);

        }