Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a price table which created in database and I use petapoco to work with data.
The reason I didn't created it as Document Type is because I have a vast number of records(The price changes every hour). But number of products are limited so i created Product as a document Type.
My problem is how I make the relation between price table and products as the prices get updated by a windows service, so the service need to know products and products' id and then create the record in price table.
I tend to simply just couple the node ID to my custom tables, when it's needed.
So basically, just add a new column on your price table called ProductNodeIdor something like that. That way you can get all prices for a given Product node.
To make the most clean solution, you could then hook into the IContentService' Deleted event, so when a Product node is deleted, the related prices will also be deleted or be marked as being inactive or whatever the business rules dictate.
To expose the product nodes to the Windows Service, you could set up an endpoint be creating a new controller class, which inherits from the SurfaceController class. Something like this:
public class MyController : SurfaceController
public JsonResult GetProducts()
// Eventually set up some kind of authentication here
IEnumerable<IPublishedContent> products = // .. fetch product nodes from Umbraco here
return Json(products.Select(x => x.Id), JsonRequestBehavior.AllowGet);
The above (not tested, written from top o' my head) method should return a JSON array of your product IDs for your windows service to consume.
Hope this makes sense :-)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted