public HttpResponseMessage DeleteAgent(PostData postData)
        {
            try
            {
                var agent = AgentManager.Instance.GetAgent(PortalSettings.PortalId, postData.ID);

                DepartmentAgentManager.Instance.DeleteAgentDepartments(postData.ID);
                AgentManager.Instance.DeleteAgent(PortalSettings.PortalId, postData.ID);

                var user = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, agent.UserID);
                var role = RoleController.Instance.GetRoleByName(PortalSettings.PortalId, "MyDnnSupportAgent");
                RoleController.DeleteUserRole(user, role, PortalSettings, false);

                return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
        }
        public HttpResponseMessage DeleteDepartment(PostData postData)
        {
            try
            {
                DepartmentManager.Instance.DeleteDepartment(PortalSettings.PortalId, postData.ID);

                return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);

                string msg = string.Empty;
                if (((System.Data.SqlClient.SqlException)(ex)).Number == 547)
                    msg = Localization.Instance.GetString(DotNetNuke.Common.Globals.ResolveUrl("~/MyDnnPackage/dnn8contest/Website/DesktopModules/MVC/MyDnnSupport/LiveChat/App_LocalResources/SharedResources"), PortalSettings.CultureCode, "DeleteDepartmentError.Text");

                return Request.CreateResponse(HttpStatusCode.InternalServerError, msg);
            }
        }