Azure Mobile Services, Part 3: Listing 1

Del operation script with push notification.

function del(id, user, request) {
  var item = null;
  var sql = "SELECT * FROM ContactItem WHERE userId = ?";
    mssql.query(sql, [user.userId], {
        success: function(results) {
            if (results.length > 0) {
                 item = results[0];
            }
        }
    });
    
   request.execute({
        success: function() {
            request.respond();
            push.wns.sendToastText04(item.PushChannel, {
                text1: item.FirstName + " " + item.LastName + " was removed as a contact!"
            });
        }
    });
}

About the Author

Eric Vogel is a Sr. Software Developer at Kunz, Leigh, & Associates in Okemos, MI. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at vogelvision@gmail.com.