I am creating a many to many-to-many relationship between the entities Invoice and Product as a hobby.
In my InvoiceProductController, I am trying to create an InvoiceProduct,but in the middle of creating of an invoiceProduct, for some reason the Product QtyOnHand did not decrease when I clicked on the create button.
I got an error when I ran the program, saying that Object reference not set to an instance of an object.
I have the evidence right here, in my InvoiceProductsController:
Product pro = db.InvoiceProducts.Find(invoiceProduct.Product).Product;
pro.QtyOnHand -= invoiceProduct.QtyOrd;
After putting it after I created the InvoiceProduct, I still got the error. It still reads object not set to an instance of an object.