public HttpResponseMessage LogoutPost([FromBody] AgentParameters agent) { try { if (MainObject.MainList.ContainsKey(agent.User.AgentId)) { CApp mpApp = MainObject.MainList[agent.User.AgentId]; var response = mpApp.Logout(agent.Logout, mpApp); if (response == HttpStatusCode.OK) { MainObject.MainEventList.Remove(agent.User.AgentId); //MainObject.MainList.Remove(agent.User.AgentId); return(Request.CreateResponse(HttpStatusCode.OK, "OK")); } else { return(Request.CreateResponse(response, "Error logout")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "Agent Not Found")); } } catch (Exception ex) { Log.logException(ex); return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message)); } }