I'm developing an API with ASP.NET, but I'm having some questions about the best way I should develop the controller layer for the products.
I'm having these questions because each product will have its own service and its own purchase path, so product1 might have a step 1, step 2 and step 3 to buy and product2 might have another step 1, another step 2 and so on.
But I think it's not interesting that my frontend has an if(Productid = 1){post("http://url/product1")}else{post("http://url/product2")}
if(Productid = 1) {
post("http://url/product1")
} else {
post("http://url/product2")
}
I believe it would be better if my frontend just make a post("http://url/product")post("http://url/product")
call and on the backend side I forward the data to the correct service.
I would like to know if there is a cleaner and more sustainable way to develop my API structure and that for each new product I don't need to add one more if(Productid==3)if(Productid==3)
to direct to the correct route in the frontend but I still don't have the knowledge of how to best structure this.