public ActionResult CategoryForm() { var s = _context.ProductCategories.ToList(); var viewmodel = new ProductSizeCategoryViewModel() { product = new Product(), productCategory = s }; viewmodel.product.Size = new List <Size>(); return(View(viewmodel)); }
public ActionResult ProductForm(ProductSizeCategoryViewModel viewmodel) { if (viewmodel.product.ProductCategoryId == 0) { var s = _context.ProductCategories.ToList(); var Tviewmodel = new ProductSizeCategoryViewModel() { product = new Product(), productCategory = s }; return(View("CategoryForm", Tviewmodel)); } return(View(viewmodel.product)); }
public ActionResult Edit(int id) { var Product = _context.Products.SingleOrDefault(c => c.ProductId == id); if (Product == null) { return(HttpNotFound()); } var viewmodel = new ProductSizeCategoryViewModel() { product = Product, productCategory = _context.ProductCategories.ToList() }; return(View("CategoryForm", viewmodel)); }