0

How do we send email and sms after saving the data using breeze. It is working fine with saving information in database, but i need to do some more operations after saving data. Can anyone help me solve this issue.

var saveChanges = function () {
   return manager.saveChanges()
     .then(saveSucceeded)
     .fail(saveFailed);    
    function saveSucceeded(saveResult) {
    log('Saved data successfully', saveResult, true);
  }

  function saveFailed(error) {
    var msg = 'Save failed: ' + getErrorMessages(error);
   logError(msg, error);
   error.message = msg;
   throw error;
  }
};

public SaveResult SaveChanges(JObject saveBundle)
{
   return _contextProvider.SaveChanges(saveBundle);
}

Thank you

1 Answers1

2

From everything I have seen Breeze and Durandal are not the droids you are looking for... They are both JavaScript libraries and you cannot send an e-mail from the browser, that I know of.

You need to do an Ajax call or something back to your controller to send an e-mail with your controller or from C# -

Sending email in .NET through Gmail

As @Pawel also pointed out, if you intercept the save in your controller, you could also trigger an e-mail there.

Community
  • 1
  • 1
PW Kad
  • 14,953
  • 7
  • 49
  • 82
  • Thank you kadumel. You mean after calling the saveChanges.. we need to call other ajax function to send email.. am i correct? – user2278861 Jun 22 '13 at 07:21
  • Somewhere in your JavaScript you need to do an Ajax post back to a controller that fires off a function to send an e-mail. That is my recommendation at least – PW Kad Jun 22 '13 at 13:58
  • You can override DbContextProvider.SaveChangesCore and send email or sms when save operation was successful. – pawel Jun 23 '13 at 09:34