public DesignTimeProductInsertViewModel() { ViewData = new ProductInsertViewData() { ProductName = "shampoo", CategoryName = "shauma", Description = "for washing", SupplierName = "Johnny", Price = 2.5m }; }
public void InsertProduct(ProductInsertViewData data) { var category = context_db.Categories.Where(c => c.CategoryName == data.CategoryName).FirstOrDefault(); var supplier = context_db.Suppliers.Where(s => s.SupplierName == data.SupplierName).FirstOrDefault(); Product item = new Product() { ProductName = data.ProductName, CategoryID = category.CategoryID, Category = category, SupplierID = supplier.SupplierID, Supplier = supplier, Description = data.Description, Price = data.Price }; proRep.InsertAction(item); context_db.SaveChanges(); Messenger.NotifyColleagues(MessageTypes.MSG_PRODUCT_INSERTED, data); }