public ActionResult Create() { ProductAddedViewModel model = new ProductAddedViewModel(); model.CategoriesData = new SelectList(_categoryService.GetAll(), "CategoryId", "CategoryName"); model.SuppliersData = new SelectList(_supplierService.GetAll(), "SupplierId", "CompanyName"); return(View(model)); }
public ActionResult Update(int id) { Product product = _productService.GetById(id); ProductAddedViewModel modeladdedviewmodel = new ProductAddedViewModel(); modeladdedviewmodel.CategoriesData = new SelectList(_categoryService.GetAll(), "CategoryId", "CategoryName"); modeladdedviewmodel.SuppliersData = new SelectList(_supplierService.GetAll(), "SupplierId", "CompanyName"); modeladdedviewmodel.Product = product; modeladdedviewmodel.CategoryId = product.CategoryId; modeladdedviewmodel.SupplierId = product.SupplierId; return(View(modeladdedviewmodel)); }