public IHttpActionResult Register(string externalId, [FromBody] UsersRegisterModel model)
        {
            try
            {
                UsersDataObject usersDO = dataAccess.GetUserByExternalID(externalId);
                if (usersDO == null)
                {
                    return(NotFound());
                }

                //var principal = Thread.CurrentPrincipal;
                ClaimsPrincipal user = Request.GetRequestContext().Principal as ClaimsPrincipal;
                if (!user.HasClaim(x => x.Type == ClaimTypes.Name))
                {
                    return(BadRequest("Invalid authentication, please request another access token"));
                }

                Claim username = user.Claims.Where(x => x.Type == ClaimTypes.Name).FirstOrDefault();
                Proxy.BioConnectAPI.SecurityTokenDto authorizedToken = bioConnectAPIProxy.RetrieveSecurityTokenByUsername(username.Value);
                if (authorizedToken == null)
                {
                    return(BadRequest("Invalid authentication, please request another access token"));
                }


                Proxy.BioConnectAPI.SecurityTokenDto newToken = new Proxy.BioConnectAPI.SecurityTokenDto
                {
                    Password  = model.Password,
                    UserName  = model.UserName,
                    UserID    = usersDO.Id,
                    Level     = model.Role,
                    Locations = new string[] { "Default" }
                };

                bioConnectAPIProxy.SaveSecurityToken(newToken, authorizedToken);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public IHttpActionResult Enroll(string externalId, [FromBody] UsersEnrollModel model)
        {
            try
            {
                UsersDataObject usersDO = dataAccess.GetUserByExternalID(externalId);
                if (usersDO == null)
                {
                    return(NotFound());
                }

                ClaimsPrincipal user = Request.GetRequestContext().Principal as ClaimsPrincipal;
                if (!user.HasClaim(x => x.Type == ClaimTypes.Name))
                {
                    return(BadRequest("Invalid authentication, please request another access token"));
                }

                Claim username = user.Claims.Where(x => x.Type == ClaimTypes.Name).FirstOrDefault();
                Proxy.BioConnectAPI.SecurityTokenDto authorizedToken = bioConnectAPIProxy.RetrieveSecurityTokenByUsername(username.Value);
                if (authorizedToken == null)
                {
                    return(BadRequest("Invalid authentication, please request another access token"));
                }

                EnrollDataModel dataModel = new EnrollDataModel
                {
                    readerID        = model.deviceID,
                    userDO          = usersDO,
                    enrollQuality   = model.enrollQuality,
                    fingerIndex     = model.fingerIndex,
                    callbackUrl     = model.callbackUrl,
                    authorizedToken = authorizedToken
                };

                enrollmentServer.Enqueue(dataModel);
                return(Content(System.Net.HttpStatusCode.Accepted, String.Format("Starting enrollment process for user: {0}", externalId)));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }