/// <summary> /// Deprecated Method for adding a new object to the ProductSize EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProductSize(ProductSize productSize) { base.AddObject("ProductSize", productSize); }
public ActionResult AddProductSize(int productId, FormCollection form) { using (var context = new SiteContainer()) { var product = context.Product.First(c => c.Id == productId); var ps = new ProductSize(); TryUpdateModel(ps, new[] { "Size" }); product.ProductSizes.Add(ps); context.SaveChanges(); return RedirectToAction("ProductDetails", "Home", new { area = "", id = productId }); } }
/// <summary> /// Create a new ProductSize object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="size">Initial value of the Size property.</param> /// <param name="productId">Initial value of the ProductId property.</param> public static ProductSize CreateProductSize(global::System.Int32 id, global::System.String size, global::System.Int32 productId) { ProductSize productSize = new ProductSize(); productSize.Id = id; productSize.Size = size; productSize.ProductId = productId; return productSize; }