samedi 25 juin 2016

Is it possible to return a boolean and redirect to another page at the same time?

I'm calling a method from my JS,

[HttpPost]
    public bool Delete(int id, string reason)
    {
        using (IDbConnection dbConnection = DbConnectionFactory.CreateConnection())
        {
            Eorder eorder = Eorder.FetchById(dbConnection, id);
            eorder.Delete(dbConnection, reason, User.Identity.Name, 88, ConfigurationManager.AppSettings["EorderAttachmentsPath"]);
        }
        return true;
    }

Which has to return either true or false.

In my JS I check if it's .done / .failed etc.

However, I'd also like to add

(new DDL.FlashMessenger(HttpContext.ApplicationInstance.Context)).AddWarning("Order has been deleted!");

And redirect to another page, as the current page (order) just got deleted and will throw 404.

Now, I am not asking how to redirect to another page with JS, but asking how I could add this FlashMessage to the top of my screen, of my desired webpage. (I could also use Alert() or bootbox.Alert(), but they're not as appealing as the FlashMessenger.

If you've got any ideas, or reccomendations on how I should handle this, please share.


Ps. I've found some sources regarding Zend Flashmessenger, but this is not the Zend one.

Aucun commentaire:

Enregistrer un commentaire