public JsonResult Reindex(ReimportClass context)
        {
            //Check permission
            if (!IsAuthorized())
            {
                return(JsonHelper.GetJsonWithWrapper(null, false, "You are not authorized for this request type.", null));
            }
            bool valid = true;

            string filter       = string.Format(" base.CTID = '{0}'", context.Ctid);
            int    processed    = 0;
            string returnStatus = "";

            //Do the request
            switch (context.TypeName)
            {
            case "credential":
            case "CredentialProfile":
                ElasticServices.Credential_UpdateIndex(filter, ref processed);
                break;

            case "organization":
            case "QAOrganization":
                ElasticServices.Organization_UpdateIndex(filter, ref processed);
                break;

            case "AssessmentProfile":
            case "assessment":
                ElasticServices.Assessment_UpdateIndex(filter, ref processed);
                break;

            case "LearningOpportunityProfile":
            case "learningopportunity":
                ElasticServices.LearningOpp_UpdateIndex(filter, ref processed);
                break;

            default:
                valid        = false;
                returnStatus = "Profile not handled";
                return(JsonHelper.GetJsonWithWrapper(null, valid, returnStatus, null));
                //break;
            }

            if (processed > 0)
            {
                returnStatus = "Seems to have worked, try searching again.";
            }
            else
            {
                valid        = false;
                returnStatus = "Hmmm - didn't seem to work.";
            }

            //Return the result
            return(JsonHelper.GetJsonWithWrapper(null, valid, returnStatus, null));
        }
        //[Authorize]
        public JsonResult Reimport(ReimportClass context)
        {
            //Check permission - maybe later
            //if ( !IsAuthorized() )
            //{
            //	return JsonHelper.GetJsonWithWrapper( null, false, "You are not authorized for this request type.", null );
            //}
            bool valid = true;

            ImportRequest mgr    = new ImportRequest();
            SaveStatus    status = new SaveStatus();

            //Do the register
            switch (context.TypeName)
            {
            case "credential":
            case "CredentialProfile":
                if (!string.IsNullOrWhiteSpace(context.Ctid))
                {
                    status = mgr.ImportCredentialByCtid(context.Ctid);
                }
                else
                if (!string.IsNullOrWhiteSpace(context.CredentialRegistryId))
                {
                    status = mgr.ImportCredential(context.CredentialRegistryId);
                }
                else
                {
                    status.AddError("Must provide either an valid CTID or envelopeId");
                }
                break;

            case "organization":
            case "QAOrganization":
                if (!string.IsNullOrWhiteSpace(context.Ctid))
                {
                    status = mgr.ImportOrganizationByCtid(context.Ctid);
                }
                else if (!string.IsNullOrWhiteSpace(context.CredentialRegistryId))
                {
                    status = mgr.ImportOrganization(context.CredentialRegistryId);
                }
                else
                {
                    status.AddError("Must provide either an valid CTID or envelopeId");
                }
                break;

            case "AssessmentProfile":
            case "assessment":
                if (!string.IsNullOrWhiteSpace(context.Ctid))
                {
                    status = mgr.ImportAssessmentByCtid(context.Ctid);
                }
                else if (!string.IsNullOrWhiteSpace(context.CredentialRegistryId))
                {
                    status = mgr.ImportAssessment(context.CredentialRegistryId);
                }
                else
                {
                    status.AddError("Must provide either an valid CTID or envelopeId");
                }

                break;

            case "LearningOpportunityProfile":
            case "learningopportunity":
                if (!string.IsNullOrWhiteSpace(context.Ctid))
                {
                    status = mgr.ImportLearningOpportuntyByCtid(context.Ctid);
                }
                else if (!string.IsNullOrWhiteSpace(context.CredentialRegistryId))
                {
                    status = mgr.ImportLearningOpportunty(context.CredentialRegistryId);
                }
                else
                {
                    status.AddError("Must provide either an valid CTID or envelopeId");
                }

                break;

            default:
                valid = false;
                status.AddError("Profile not handled");
                break;
            }
            string returnStatus = "";

            if (status.HasErrors)
            {
                valid        = false;
                returnStatus = string.Join("<br/>", status.GetAllMessages().ToArray());
            }
            else if (status.GetAllMessages().Count > 0)
            {
                returnStatus = string.Join("<br/>", status.GetAllMessages().ToArray());
            }
            else
            {
                returnStatus = "Seems to have worked??";
                ElasticServices.UpdateElastic(true);
            }


            //Return the result
            return(JsonHelper.GetJsonWithWrapper(null, valid, returnStatus, null));
        }