Updating the admin website
As with the order processor, we can do a small modification to the admin website to call the Notification/PostProductNews
action when a new product is created, which will send push notifications to all customers. The procedure for this is pretty much the same, but here, I created a separate helper class to separate the logic from the controller:
private readonly MobileServiceClient _mobileService; public Notifications() { var mobileServiceUrl = ConfigurationManager.AppSettings["mobileServiceUrl"]; var mobileServiceKey = ConfigurationManager.AppSettings["mobileServiceKey"]; this._mobileService = new MobileServiceClient(mobileServiceUrl, mobileServiceKey); } public async Task NotifyPostProductNews(int productId) { dynamic data = new ExpandoObject(); data.productId = productId; await this._mobileService.InvokeApiAsync<object, dynamic>("Notification/PostProductNews", data); }
This method can be called by...