Esempio n. 1
0
 public void CreateProductInDatabase(Product product)
 {
     using (var db = new AdventureWorks2008R2Entities())
     {
         db.Products.AddObject(product);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
        public ActionResult CreateProduct(Product product)
        {
            product.ProductNumber = "FR-R12U-48";
            product.MakeFlag = true;
            product.FinishedGoodsFlag = true;
            product.SafetyStockLevel = 500;
            product.ReorderPoint = 375;
            product.StandardCost = 288;
            product.ListPrice = 388;
            product.DaysToManufacture = 1;
            product.SellStartDate = new DateTime(2005, 7, 1);
            product.rowguid = Guid.NewGuid();
            product.ModifiedDate = DateTime.Now;

            CreateProductInDatabase(product);

            return RedirectToAction("Index");
        }
Esempio n. 3
0
        public IQueryable<Product> Load()
        {
            IList<Product> products = new List<Product>();
            Product product;
            ProductPhoto prodPhoto;
            ProductProductPhoto prodProdPhoto;

            product = new Product();
            product.Name = "Road-150 Red, 48";
            prodPhoto = new ProductPhoto();
            prodPhoto.PhotoPath = "~/Content/Images/SampleCycles/cycle1.gif";
            prodProdPhoto = new ProductProductPhoto() { ProductPhoto = prodPhoto };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            product = new Product();
            product.Name = "Touring-2000 Blue, 60";
            prodPhoto = new ProductPhoto();
            prodPhoto.PhotoPath = "~/Content/Images/SampleCycles/cycle2.gif";
            prodProdPhoto = new ProductProductPhoto() { ProductPhoto = prodPhoto };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            product = new Product();
            product.Name = "Mountain-100 Black, 42";
            prodPhoto = new ProductPhoto();
            prodPhoto.PhotoPath = "~/Content/Images/SampleCycles/cycle3.gif";
            prodProdPhoto = new ProductProductPhoto() { ProductPhoto = prodPhoto };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            product = new Product();
            product.Name = "Road-350-W Yellow, 44";
            prodPhoto = new ProductPhoto();
            prodPhoto.PhotoPath = "~/Content/Images/SampleCycles/cycle4.jpg";
            prodProdPhoto = new ProductProductPhoto() { ProductPhoto = prodPhoto };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            return products.AsQueryable<Product>();
        }
Esempio n. 4
0
        public ActionResult CreateProduct()
        {
            Product product = new Product();

            return View(product);
        }
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="productID">Initial value of the ProductID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="productNumber">Initial value of the ProductNumber property.</param>
 /// <param name="makeFlag">Initial value of the MakeFlag property.</param>
 /// <param name="finishedGoodsFlag">Initial value of the FinishedGoodsFlag property.</param>
 /// <param name="safetyStockLevel">Initial value of the SafetyStockLevel property.</param>
 /// <param name="reorderPoint">Initial value of the ReorderPoint property.</param>
 /// <param name="standardCost">Initial value of the StandardCost property.</param>
 /// <param name="listPrice">Initial value of the ListPrice property.</param>
 /// <param name="daysToManufacture">Initial value of the DaysToManufacture property.</param>
 /// <param name="sellStartDate">Initial value of the SellStartDate property.</param>
 /// <param name="rowguid">Initial value of the rowguid property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 public static Product CreateProduct(global::System.Int32 productID, global::System.String name, global::System.String productNumber, global::System.Boolean makeFlag, global::System.Boolean finishedGoodsFlag, global::System.Int16 safetyStockLevel, global::System.Int16 reorderPoint, global::System.Decimal standardCost, global::System.Decimal listPrice, global::System.Int32 daysToManufacture, global::System.DateTime sellStartDate, global::System.Guid rowguid, global::System.DateTime modifiedDate)
 {
     Product product = new Product();
     product.ProductID = productID;
     product.Name = name;
     product.ProductNumber = productNumber;
     product.MakeFlag = makeFlag;
     product.FinishedGoodsFlag = finishedGoodsFlag;
     product.SafetyStockLevel = safetyStockLevel;
     product.ReorderPoint = reorderPoint;
     product.StandardCost = standardCost;
     product.ListPrice = listPrice;
     product.DaysToManufacture = daysToManufacture;
     product.SellStartDate = sellStartDate;
     product.rowguid = rowguid;
     product.ModifiedDate = modifiedDate;
     return product;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProducts(Product product)
 {
     base.AddObject("Products", product);
 }
 public void CreateProduct(Product product)
 {
     this._db.Products.AddObject(product);
     this._db.SaveChanges();
 }