コード例 #1
0
        public void UpsertAttribute_InsertSecond()
        {
            Mock<IProductRepository> productRepo = new Mock<IProductRepository>();
            Mock<IImageResizer> imageResizer = new Mock<IImageResizer>();
            ProductService service = new ProductService(productRepo.Object, imageResizer.Object, ServiceBuilder.Saver.Object);
            Product oneAtt = new Product();
            MetaAttribute cost = new MetaAttribute();
            cost.Id = 3;
            cost.DataTypeEnum = MetaAttribute.MetaAttributeDataType.CURRENCY;

            MetaAttribute height = new MetaAttribute();
            height.Id = 6;
            height.DataTypeEnum = MetaAttribute.MetaAttributeDataType.INTEGER;

            ProductAttribute costAtt = new ProductAttribute();
            costAtt.Id = 2;
            costAtt.MetaAttribute = cost;
            oneAtt.ProductAttributes.Add(costAtt);

            ProductAttribute heightAtt = new ProductAttribute();
            heightAtt.Id = 8;
            heightAtt.MetaAttribute = height;

            productRepo.Expect(repo => repo.CreateProductAttribute(height)).Returns(heightAtt);
            service.UpsertAttribute(oneAtt, height, "69");

            Assert.AreEqual(2, oneAtt.ProductAttributes.Count);
        }
コード例 #2
0
ファイル: ProductHelper.cs プロジェクト: liammclennan/Herald
        private static string SelectableAttribute(HtmlHelper helper, MetaAttribute ma, ProductAttribute attribute)
        {
            SelectList listData = (attribute != null)
                        ? new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text", (object)attribute.RawValue)
                        : new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text");

            return helper.DropDownList(ma.ProductAttributeHtmlControlName, listData, OPTION_LABEL);
        }
コード例 #3
0
ファイル: ProductHelper.cs プロジェクト: liammclennan/Herald
        /// <summary>Generate a control for displaying an attribute.</summary>
        /// <param name="helper"></param><param name="ma"></param><param name="attribute"></param>
        /// <returns></returns>
        public static string AttributeControl(HtmlHelper helper, MetaAttribute ma, ProductAttribute attribute)
        {
            string result = (ma.DataTypeEnum == MetaAttribute.MetaAttributeDataType.CURRENCY) ? "$" : "&nbsp;";

            return (ma.HasChoices)
                ? result + SelectableAttribute(helper, ma, attribute)
                : result + NonSelectableAttribute(helper, ma, attribute);
        }
コード例 #4
0
        public void UpsertAttribute_Clear()
        {
            ProductService service = SetupProductService();
            Product oneAtt = new Product();
            MetaAttribute cost = new MetaAttribute();
            cost.Id = 3;
            cost.DataTypeEnum = MetaAttribute.MetaAttributeDataType.CURRENCY;
            ProductAttribute costAtt = new ProductAttribute();
            costAtt.Id = 2;
            costAtt.MetaAttribute = cost;
            oneAtt.ProductAttributes.Add(costAtt);

            service.UpsertAttribute(oneAtt, cost, "");
            Assert.AreEqual(1, oneAtt.ProductAttributes.Count);
        }
コード例 #5
0
        public void UpsertAttribute_Insert()
        {
            Mock<IProductRepository> productRepo = new Mock<IProductRepository>();
            ProductService service = SetupProductService();
            Product noAtts = new Product();
            MetaAttribute metaAttribute = new MetaAttribute();
            metaAttribute.Id = 5;
            metaAttribute.DataTypeEnum = MetaAttribute.MetaAttributeDataType.STRING;

            service.UpsertAttribute(noAtts, metaAttribute, "");
            Assert.IsTrue(noAtts.ProductAttributes.Count == 0);

            ProductAttribute catAtt = new ProductAttribute();
            catAtt.Id = 1;
            catAtt.MetaAttribute = metaAttribute;
            catAtt.Product = noAtts;

            productRepo.Expect(repo => repo.CreateProductAttribute(metaAttribute)).Returns(catAtt);

            service.UpsertAttribute(noAtts, metaAttribute, "cat");
            Assert.AreEqual(1, noAtts.ProductAttributes.Count);
        }
コード例 #6
0
ファイル: ProductHelper.cs プロジェクト: liammclennan/Herald
 private static string NonSelectableAttribute(HtmlHelper helper, MetaAttribute ma, ProductAttribute attribute)
 {
     return (attribute != null)
                 ? helper.TextBox(ma.ProductAttributeHtmlControlName, attribute.ControlFormattedValue)
                 : helper.TextBox(ma.ProductAttributeHtmlControlName);
 }
コード例 #7
0
 partial void DeleteProductAttribute(ProductAttribute instance);
コード例 #8
0
 partial void UpdateProductAttribute(ProductAttribute instance);
コード例 #9
0
 partial void InsertProductAttribute(ProductAttribute instance);
コード例 #10
0
		private void detach_ProductAttributes(ProductAttribute entity)
		{
			this.SendPropertyChanging();
			entity.MetaAttribute = null;
		}
コード例 #11
0
		private void attach_ProductAttributes(ProductAttribute entity)
		{
			this.SendPropertyChanging();
			entity.Product = this;
		}