public HttpResponseMessage TransferPost([FromBody] AgentParameters agent) { try { if (MainObject.MainList.ContainsKey(agent.User.AgentId)) { object obj = new CSimpleService(agent.Transfer.ServiceId, agent.Transfer.ServiceName, agent.Transfer.ServiceType); CApp mpApp = MainObject.MainList[agent.User.AgentId]; //If Consulting or Conferenced, transfer the call to the consulted party if (mpApp.CurrentState is CStateConsulting || mpApp.CurrentState is CStateConference) { mpApp.Transfer(); return(Request.CreateResponse(HttpStatusCode.OK, "OK")); } else { if (!string.IsNullOrEmpty(agent.Transfer.PhoneNumber)) { if (obj is CExternalRoute) { mpApp.Transfer(agent.Transfer.PhoneNumber, (CExternalRoute)obj); return(Request.CreateResponse(HttpStatusCode.OK, "OK (External Route)")); } else { mpApp.Transfer(agent.Transfer.PhoneNumber); return(Request.CreateResponse(HttpStatusCode.OK, "OK (PhoneNumber)")); } } else if (obj is CUser) { mpApp.Transfer((CUser)obj); return(Request.CreateResponse(HttpStatusCode.OK, "OK (User)")); } else if (obj is CSimpleService) { mpApp.Transfer((CSimpleService)obj); return(Request.CreateResponse(HttpStatusCode.OK, "OK (Simple Service)")); } return(Request.CreateResponse(HttpStatusCode.BadRequest, "")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "")); } } catch (Exception ex) { Log.logException(ex); return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message + "PhoneNumber: " + agent.Transfer.PhoneNumber)); } }