• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Product类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Product的典型用法代码示例。如果您正苦于以下问题:C# Product类的具体用法?C# Product怎么用?C# Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Product类属于命名空间,在下文中一共展示了Product类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProductFactory

            public ProductFactory(Parameters parameters)
            {
                try
                {
                    using (var server = new VentsCad())
                    {
                        switch (parameters.Name)
                        {
                            case "spigot":                                
                                product = new Spigot(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Height);
                                break;
                            case "dumper":
                                var material = new string[] { parameters.Materials[0].Value, parameters.Materials[0].Thikness, parameters.Materials[0].Name, parameters.Materials[0].Code };
                                product = new Dumper(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Height, true, material);
                                break;
                            case "montageFrame":                                
                                product = new MontageFrame(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Lenght, parameters.Sizes[0].Additional1, parameters.Materials[0]);
                                break;
                            default:
                                break;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                }

                
            }
开发者ID:GitHubVents,项目名称:AirVentsCad,代码行数:30,代码来源:ProductFactory.cs


示例2: SelectByProductID

        public Product SelectByProductID(int ProductID)
        {
            string query = "select * from Product WHERE ProductID = @ProductID";
            List<SqlParameter> lstParams = new List<SqlParameter>();
            lstParams.Add(new SqlParameter("@ProductID", ProductID));

            DataTable dt = DBUtility.SelectData(query, lstParams);

            Product objProduct = new Product();
            if (dt.Rows.Count > 0)
            {
                objProduct.Name = dt.Rows[0]["Name"].ToString();
                objProduct.CreateDate = Convert.ToDateTime(dt.Rows[0]["CreateDate"]);
                objProduct.DesignFiles = dt.Rows[0]["DesignFiles"].ToString();
                objProduct.Status = dt.Rows[0]["Status"].ToString();
                objProduct.Description = dt.Rows[0]["Description"].ToString();
                objProduct.Size = dt.Rows[0]["Size"].ToString();
                objProduct.Colors = dt.Rows[0]["Colors"].ToString();
                objProduct.Type = dt.Rows[0]["Type"].ToString();
                objProduct.CustomerID = Convert.ToInt32(dt.Rows[0]["CustomerID"]);
                objProduct.ProductID = Convert.ToInt32(dt.Rows[0]["ProductID"]);
              
            }

            return objProduct;
        }
开发者ID:paulomi-mahidharia,项目名称:OfficeAutomationAndProductionPlanningApplication,代码行数:26,代码来源:ProductLogic.cs


示例3: SingleProductViewModel

        public SingleProductViewModel(Product p, MerchantTribeApplication mtapp)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Price Product " + p.ProductName))
            {
                this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null, mtapp.CurrentlyActiveSales);
            }
            this.IsFirstItem = false;
            this.IsLastItem = false;
            this.Item = p;
            using (profiler.Step("Image Url Product" + p.ProductName))
            {
                this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall(
                    mtapp,
                    p.Bvin,
                    p.ImageFileSmall,
                    mtapp.IsCurrentRequestSecure());
            }
            using (profiler.Step("Product Link " + p.ProductName))
            {
                this.ProductLink = UrlRewriter.BuildUrlForProduct(p,
                                                mtapp.CurrentRequestContext.RoutingContext,
                                                string.Empty);
            }
        }
开发者ID:mikeshane,项目名称:MerchantTribe,代码行数:26,代码来源:SingleProductViewModel.cs


示例4: CreateProduct

        public ActionResult CreateProduct(Product p, HttpPostedFileBase file)
        {
            string imgPath = "/Content/images/product";
            string path = "";
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string pic = System.IO.Path.GetFileName(file.FileName);
                    path = System.IO.Path.Combine(
                                           Server.MapPath("~" + imgPath), pic);
                    // file is uploaded
                    file.SaveAs(path);
                    p.ProductPictureUrl = imgPath + "/" + file.FileName;
                }

                p.CreatedDate = DateTime.Now;
                _productRepository.Add(p);
                _productRepository.Save();
                int i = p.ProductId;
                return Json(i);
            }
            else
            {
                int wrongData = -2;
                return Json(wrongData);
            }
        }
开发者ID:goodwin3000,项目名称:Catalog,代码行数:28,代码来源:AdminController.cs


示例5: btnAdd_Click

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        selectedProduct = new Product();
        this.selectedProduct.Course_id = course_id.ToString();

        if (Page.IsValid)
        {
            CartItemList cart = CartItemList.GetCart();
            int locCount = cart.Count;
            locCount = locCount + 1;
            this.selectedProduct.assignmentNumber = locCount.ToString();
            this.selectedProduct.aGUID = Guid.NewGuid().ToString();
            this.selectedProduct.Num_Assignment = locCount;
            CartItem cartItem = new CartItem();

            int Num_Assignments=0;
            int assignment = 1; //will be produced from loop according to Num_Assignments
            cart = CartItemList.GetCart();
            cartItem = cart[selectedProduct.Course_id];

            if (cartItem == null)
            {
                cart.AddItem(selectedProduct, Num_Assignments,assignment);
            }
            else
            {
                cart.AddItem(selectedProduct, Num_Assignments, assignment);
                cartItem.AddQuantity(1);
            }
            this.DisplayCart();

        }
    }
开发者ID:cweber-wou,项目名称:capstone,代码行数:33,代码来源:OrderPage.aspx.cs


示例6: AddToCart

        public void AddToCart(Product product, decimal price)
        {
            // Get the matching cart and product instances
            var cartItem = db.CartItems.SingleOrDefault(
                c => c.CartID == ShoppingCartId
                && c.ProductID == product.ProductID);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new CartItem
                {
                    ProductID = product.ProductID,
                    CartID = ShoppingCartId,
                    Amount = 1,
                    Price = price,
                    Creation = DateTime.Now
                };

                db.CartItems.AddObject(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Amount++;
            }

            // Save changes
            db.SaveChanges();
        }
开发者ID:rogerex,项目名称:shopnet,代码行数:30,代码来源:ShoppingCart.cs


示例7: CanStoreAProduct

        public void CanStoreAProduct()
        {
            //Database.SetInitializer(new DropCreateDatabaseAlways<CoffeeShopContext>());
              long id;
              using (var session = sessionFactory.OpenSession())
              using (var tx = session.BeginTransaction())
              {
            var repository = new Repository<Product>(session);
            var product = new Product
                      {
                        Name = "Coffee 1",
                        Price = 10.4m
                      };

            repository.MakePersistent(product);
            id = product.Id;
            tx.Commit();
              }

              using (var session = sessionFactory.OpenSession())
              using (session.BeginTransaction())
              {
            var repository = new Repository<Product>(session);
            Product product = repository.GetById(id);

            product.Satisfy(p => p.Name == "Coffee 1" && p.Price == 10.4m);
              }
        }
开发者ID:horsdal,项目名称:Restbucks-on-Nancy,代码行数:28,代码来源:DataTests.cs


示例8: IsSatisfiedBy

        public bool IsSatisfiedBy(Product product)
        {
            if (_sizeIds.Count() > 0 )
                return _sizeIds.Any(s => product.Title.Products.Any(p => p.Size.Id == s));

            return true;
        }
开发者ID:modulexcite,项目名称:Fork_AgathasStorefront_ASPNET_MVC,代码行数:7,代码来源:ProductIsInSizeSpecification.cs


示例9: add

        public static void add(Product product)
        {
            var existingProduct = false;
            Product fetchedProduct;

            if (product.Id != 0)
            {
                throw new
                Exception(@"Posted products cannot
              contain an id");
            }

            try
            {
                fetchedProduct = get(product.Name);
                existingProduct = true;
            }
            catch (Exception)
            {
                //this is actually good that we are here. Means we didn't
                //find an existing product so it is OK to insert;
                product.Id = ProductsRepository.data.Select(x => x.Id).Max() + 1;

                var data = ProductsRepository.data.ToList();
                data.Add(product);
                ProductsRepository.data = data;
            }

            if (existingProduct)
            {
                throw new
                Exception(@"The product name you are
              attempting to insert already exists.");
            }
        }
开发者ID:mikaelo,项目名称:SecureWebAPI,代码行数:35,代码来源:ProductsRepository.cs


示例10: TestActiveAtSpecification

        public void TestActiveAtSpecification()
        {
            var productSpecification1 = new ProductSpecification
            {
                ActiveFrom = DateTime.Now.AddDays(-3),
                ActiveUntil = DateTime.Now.AddDays(3)
            };

            var productSpecification2 = new ProductSpecification
            {
                ActiveFrom = DateTime.Now.AddDays(-6),
                ActiveUntil = DateTime.Now.AddDays(-3)
            };

            var productSpecification3 = new ProductSpecification
            {
                ActiveFrom = DateTime.Now.AddDays(-9),
                ActiveUntil = DateTime.Now.AddDays(-6)
            };

            var product = new Product
            {
                ProductSpecifications =
                    new Collection<ProductSpecification>
                                  {
                                      productSpecification1,
                                      productSpecification2,
                                      productSpecification3
                                  }
            };

            var actual = product.ActiveAt(DateTime.Now.AddDays(-8));

            Assert.AreEqual(productSpecification3, actual);
        }
开发者ID:dibble-james,项目名称:Ketchup,代码行数:35,代码来源:ProductTests.cs


示例11: deleteProduct

 public void deleteProduct(Product p)
 {
     if (db.Products.Contains(p)&& p!=null)
     {
         db.Products.Remove(p);
     }
 }
开发者ID:jappedk,项目名称:webshop,代码行数:7,代码来源:Service.cs


示例12: activeSelect

 public void activeSelect(User _user, Product _product)
 {
     if (_product.Active == false)
     {
         throw new NonActiveProductException(_user, _product);
     }
 }
开发者ID:Stg3orge,项目名称:Gundamnation,代码行数:7,代码来源:InsertCashTransaction.cs


示例13: ImportTags

        internal static void ImportTags(Product product, List<string> tagsList, UploadConfig config)
        {
            TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
            CatalogManager catalogManager = CatalogManager.GetManager();

            FlatTaxonomy tagsTaxonomy = taxonomyManager.GetTaxonomies<FlatTaxonomy>().Where(t => t.Name == "Tags").SingleOrDefault();

            foreach (var tagString in tagsList)
            {
                try
                {
                    Taxon tag = GetTagIfItExsistsOrCreateOneIfItDoesnt(tagString, tagsTaxonomy, taxonomyManager);

                    SetTagProperties(tag, tagString);

                    taxonomyManager.SaveChanges();

                    if (product.Organizer.TaxonExists("Tags", tag.Id) == true)
                    {
                        continue;        // Product already linked to Tag
                    }

                    product.Organizer.AddTaxa("Tags", tag.Id);

                    catalogManager.SaveChanges();
                }
                catch
                {
                    //catching so even if one fails rest goes on
                }
            }
        }
开发者ID:vkoppaka,项目名称:ProductUploadPackage,代码行数:32,代码来源:TagsImporter.cs


示例14: EditProduct

        public ActionResult EditProduct(Product product)
        {
            products.Update(product);
            products.Commit();

            return RedirectToAction("ProductList");
        }
开发者ID:keevan,项目名称:Invoice-Management-System,代码行数:7,代码来源:AdminController.cs


示例15: GetProduct

        private string GetProduct(TextBox txtProductID,
                          ref Product product)
        {
            string result = "";

            try
            {
                int productID = Int32.Parse(txtProductID.Text);
                var client = new ProductServiceClient();
                product = client.GetProduct(productID);

                var sb = new StringBuilder();
                sb.Append("ProductID:" +
                    product.ProductID.ToString() + "\n");
                sb.Append("ProductName:" +
                    product.ProductName + "\n");
                sb.Append("UnitPrice:" +
                    product.UnitPrice.ToString() + "\n");
                sb.Append("RowVersion:");
                foreach (var x in product.RowVersion.AsEnumerable())
                {
                    sb.Append(x.ToString());
                    sb.Append(" ");
                }
                result = sb.ToString();

            }
            catch (Exception ex)
            {
                result = "Exception: " + ex.Message.ToString();
            }

            return result;
        }
开发者ID:ah16269,项目名称:rest-web-api-wcf,代码行数:34,代码来源:MainWindow.xaml.cs


示例16: GetProductsByPartialName

        public static List<Product> GetProductsByPartialName(string partialName)
        {
            List<Product> results = new List<Product>(); //empty list

            string query = "SELECT ProductCode, Name " +
                           "FROM Products " +
                           "WHERE Name LIKE @PartialName " +
                           "ORDER BY ProductCode";

            using (SqlConnection con = new SqlConnection(GetConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    cmd.Parameters.AddWithValue("@PartialName", "%" + partialName + "%");

                    con.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read()) //while there is still another record
                        {
                            Product p = new Product();
                            p.ProductCode = reader["ProductCode"].ToString();
                            p.Name = reader["Name"].ToString();
                            results.Add(p); //add to the list
                        }
                    }
                }
            }

            return results;
        }
开发者ID:whitneyhaddow,项目名称:wcf-service-and-test-client-app-repairs,代码行数:31,代码来源:ProductDB.cs


示例17: EmbeddingOfInstanceOfCustomReferenceTypeWithFieldsIsCorrect

		public virtual void EmbeddingOfInstanceOfCustomReferenceTypeWithFieldsIsCorrect()
		{
			// Arrange
			var product = new Product
			{
				Name = "Red T-shirt",
				Price = 995.00
			};

			const string updateCode = "product.Price *= 1.15;";

			const string input1 = "product.Name";
			const string targetOutput1 = "Red T-shirt";

			const string input2 = "product.Price";
			const double targetOutput2 = 1144.25;

			// Act
			string output1;
			double output2;

			using (var jsEngine = CreateJsEngine())
			{
				jsEngine.EmbedHostObject("product", product);
				jsEngine.Execute(updateCode);

				output1 = jsEngine.Evaluate<string>(input1);
				output2 = jsEngine.Evaluate<double>(input2);
			}

			// Assert
			Assert.AreEqual(targetOutput1, output1);
			Assert.AreEqual(targetOutput2, output2);
		}
开发者ID:nagaozen,项目名称:MsieJavaScriptEngine,代码行数:34,代码来源:InteropTestsBase.cs


示例18: AdminProductViewModel

 public AdminProductViewModel(Product product)
 {
     ProductID = product.ProductID;
       BrandID = product.BrandID;
       Condition = product.ProductConditions.FirstOrDefault().ProductConditionID;
       Gender = product.Gender;
       ProductName = product.ProductName;
       ModelName = product.ModelName;
       ModelNumber = product.ModelNumber;
       SerialNumber = product.SerialNumber;
       CaseSize = product.CaseSize;
       CaseMaterial = product.CaseMaterial;
       Bezel = product.Bezel;
       Crystal = product.Crystal;
       DialColour = product.DialColour;
       Movement = product.Movement;
       Functions = product.Functions;
       Strap = product.Strap;
       WaterResistant = product.WaterResistant;
       RetailPrice = product.RetailPrice;
       BoxPapers = product.BoxPapers;
       Warranty = product.Warranty;
       ProductImages = new List<AdminProductImageViewModel>();
       foreach (ProductImage image in product.ProductImages) {
     ProductImages.Add(new AdminProductImageViewModel(image));
       }
       NewArrival = product.NewArrival.GetValueOrDefault();
       HotDeal = product.HotDeal.GetValueOrDefault();
       Sold = product.Sold.GetValueOrDefault();
 }
开发者ID:jonezy,项目名称:ProductSite,代码行数:30,代码来源:AdminProductViewModel.cs


示例19: Init

		public void Init()
		{
			var en = CultureInfo.CreateSpecificCulture("en");

			Thread.CurrentThread.CurrentCulture	= en;
			Thread.CurrentThread.CurrentUICulture = en;

			helper = new FormHelper();

			subscription = new Subscription();
			mock = new MockClass();
			months = new[] {new Month(1, "January"), new Month(1, "February")};
			product = new Product("memory card", 10, (decimal) 12.30);
			user = new SimpleUser();
			users = new[] { new SimpleUser(1, false), new SimpleUser(2, true), new SimpleUser(3, false), new SimpleUser(4, true) };
			mock.Values = new[] { 2, 3 };

			var controller = new HomeController();
			var context = new ControllerContext();

			context.PropertyBag.Add("product", product);
			context.PropertyBag.Add("user", user);
			context.PropertyBag.Add("users", users);
			context.PropertyBag.Add("roles", new[] { new Role(1, "a"), new Role(2, "b"), new Role(3, "c") });
			context.PropertyBag.Add("sendemail", true);
			context.PropertyBag.Add("confirmation", "abc");
			context.PropertyBag.Add("fileaccess", FileAccess.Read);
			context.PropertyBag.Add("subscription", subscription);
			context.PropertyBag.Add("months", months);
			context.PropertyBag.Add("mock", mock);

			helper.SetController(controller, context);
		}
开发者ID:smoothdeveloper,项目名称:Castle.MonoRail,代码行数:33,代码来源:FormHelperCheckboxFieldListTestCase.cs


示例20: Add

        public ActionResult Add([Bind(Prefix = "AddForm")] ProductsAddForm form)
        {
            var model = new ProductsAddViewModel { AddForm = form };

            if (ModelState.IsValid)
            {
                using (var transaction = _session.BeginTransaction())
                {
                    var product = new Product
                                  {
                                      Name = form.Name,
                                      Description = form.Description ?? string.Empty
                                  };

                    var primaryVariant = new ProductVariant
                                         {
                                             Price = form.Price.Value,
                                             Sku = form.Sku ?? string.Empty,
                                             Product = product
                                         };

                    product.Variants = new[] { primaryVariant };

                    _session.Save(product);
                    transaction.Commit();
                    return RedirectToAction("View", new { id = product.Id });
                }
            }

            SetupAddViewModel(model);
            return View(model);
        }
开发者ID:1andy,项目名称:plcdev,代码行数:32,代码来源:ProductsController.cs



注:本文中的Product类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ProductCategory类代码示例发布时间:2022-05-24
下一篇:
C# ProcessorPin类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap