Example #1
0
 public ProductViewModel(Product product, string categoryName)
 {
     this.Id = product.ProductId;
     this.Name = product.Name;
     this.Price = product.Price;
     this.Quantity = product.Quantity;
     this.CategoryName = categoryName;
     this.Manufacturer = product.Manufacturer;
     this.UnitOfMeasure = product.UnitOfMeasure;
     this.SupplierPrice = product.SupplierPrice;
 }
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.AddObject(product);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CategoriesId = new SelectList(db.Categories, "Id", "Name", product.CategoriesId);
            return View(product);
        }
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         db.Products.Attach(product);
         db.ObjectStateManager.ChangeObjectState(product, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CategoriesId = new SelectList(db.Categories, "Id", "Name", product.CategoriesId);
     return View(product);
 }
Example #4
0
 public InquireViewModel(Product product, string categoryName, decimal specificPrice)
     : base(product, categoryName)
 {
     this.SpecificItemAllInStockPrice = specificPrice;
 }
 /// <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="price">Initial value of the Price property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 /// <param name="categoriesId">Initial value of the CategoriesId property.</param>
 /// <param name="unitOfMeasure">Initial value of the UnitOfMeasure property.</param>
 /// <param name="manufacturer">Initial value of the Manufacturer property.</param>
 /// <param name="supplierPrice">Initial value of the SupplierPrice property.</param>
 public static Product CreateProduct(global::System.Int32 productId, global::System.String name, global::System.Decimal price, global::System.Int32 quantity, global::System.Int32 categoriesId, global::System.String unitOfMeasure, global::System.String manufacturer, global::System.Decimal supplierPrice)
 {
     Product product = new Product();
     product.ProductId = productId;
     product.Name = name;
     product.Price = price;
     product.Quantity = quantity;
     product.CategoriesId = categoriesId;
     product.UnitOfMeasure = unitOfMeasure;
     product.Manufacturer = manufacturer;
     product.SupplierPrice = supplierPrice;
     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);
 }