public string Unsubscribe(int id) { var subscription = _db.Subscriptions.SingleOrDefault(r => r.Id == id); var user = _db.Users.SingleOrDefault(r => r.Id == subscription.UserId); var clientRecurring = new eWay.Rebill.Test.manageRebill_testSoapClient(); var ewayHeader = GetRebillEwayHeader(); var result = clientRecurring.DeleteRebillEvent(ref ewayHeader, user.RebillCustomerID, subscription.RebillID).Result; if (result.ToLower() == "success") { _db.Subscriptions.Remove(_db.Subscriptions.SingleOrDefault(r => r.Id == id)); _db.SaveChanges(); try { var body = "<h1>Successfully Unsubscribed</h1>"; body += "<p>We hope you enjoyed our services.</p>"; body += "<p>The pet owner " + subscription.User.FullName + " and pet named " + subscription.Pet.Name + " will now stop receiving the following product monthly:</p>"; body += "<p>Product name: " + subscription.Product.DisplayName + "</p>"; body += "<p>Amount: $" + subscription.Product.Price + "</p>"; body += "<p>Thank you,</p>"; body += "<p>Felix and Rover Team ^.^</p>"; EmailHelper.SendEmail(subscription.User.Email, "Felix and Rover (Unsubscribed)", body); } catch (Exception) { } return "success"; } return "fail"; }