Click here to Skip to main content
15,886,104 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm working on an existing project in .NET MVC.

I have the following API. I need to create an alert popup in all VIEWS presenting call_id and user_id resulted from the call. Is that feasible?

public partial class sos_message
        {
            public int call_id { get; set; }
            public String user_id { get; set; }
            public String message { get; set; }
            public int StatusCode { get; set; }

        }
public System.Web.Http.Results.JsonResult<String> Get_SOS_Alert(int call_id, String u_id)
        {
            using (EMSMVCEntities entities = new EMSMVCEntities())
            {

                var jsonResult = JsonConvert.Null;

                try
                {

                    sos_message message = new sos_message()
                    {
                        call_id = call_id,
                        user_id = u_id,
                        message = "SOS",
                        StatusCode = 1
                    };

                    jsonResult = JsonConvert.SerializeObject(message);

                }
                catch (SqlException ex)
                {
                    error_message error_status = new error_message()
                    {
                        StatusCode = 0
                    };

                    jsonResult = JsonConvert.SerializeObject(error_status);
                }

                return Json(jsonResult);

            }
        }


What I have tried:

I've tried to develop a new controller like this example Create an Alert Message from Controller View Using JavaScript Alert MessageBox[^] nut I don't know how to call it when the API is called and how to show it in all the available views.
Posted
Updated 9-Sep-20 5:54am

1 solution

The WebApi cannot show any user interface at all. That's up the the application using the Api, not the Api itself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900