I want the user to add several products in one id. I know that the relationship is one to many, but how do we program the interface and logic? To save several products in one ID
Hello Sh.
To clarify, you don't want several products with one Id. You want a common entity with multiple products (example: an Order or a Delivery can have with multiple products associated).
You can do it in two ways.
The easy one: you first create the Order, and use that Id to add products one by one.
The better one: when you are editing the Order you also fill a List variable with Products and save all at once, getting the OrderId from the CreateOrUpdate.
But you have to start by watching this class to understand the concept.
Have a look at the training videos. It really helps. There is an example just like your scenario on the Becoming a Reactive Developer course
Hello Ahmed,
I have uploaded a demo OML where I have created One to Many Relations with One user with many products as shown below:
thanks but i know how to do this, my problem with interface and logic . how can i told the InterFase i want all these product in the same id
for example; i want to do E-shop so i want add a lot of product in the cart to do an order
As you can see below product entity has one user identifier.
Headphone & Laptop has been ordered by UserID: 7
Same
Desktop has been ordered by UserID: 10
So by giving User Identifier, you can list many products under same user identifier
Hello Sh,
Whenever you are going to save new product details, you have to give userId for that foreign key right. You can pass GetUserId() to Product.userId field. It will automatically get the current userId who logged in on server.
Ex: You are logged in and adding new product detail to table. It will automatically assign to userId to Product.userId.
Or you can put assign before save action called,
Thanks,
Bala.
You have to create product id identifier in the user table