Esempio n. 1
0
        public HttpResponseMessage AuthenticateAndParse(string userId, string pw, byte[] voiceData)
        {
            VoiceItWrapper wrapper = new VoiceItWrapper();

            var result = wrapper.authenticationByByteData(userId, pw, voiceData);

            if (string.IsNullOrEmpty(result))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "The voice auth server did not respond back with a result"));
            }

            //now parse
            var authResponse = JsonConvert.DeserializeObject <AuthResponse>(result);

            if (authResponse == null)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while deserializing response from voice auth server"));
            }

            bool r = ParseAuthResponse(authResponse);

            if (r == false)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while parsing and executing the voice command"));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Esempio n. 2
0
        public HttpResponseMessage DeleteUser(UserModel userModel)
        {
            var voiceItWrapper = new VoiceItWrapper();
            var result         = voiceItWrapper.deleteUser(userModel.UserId, userModel.Password);

            if (string.IsNullOrEmpty(result))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "The server did not respond back with a result"));
            }


            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Esempio n. 3
0
        public HttpResponseMessage DeleteEnrollment(EnrollmentModel enrollmentModel)
        {
            var voiceItWrapper = new VoiceItWrapper();

            if (enrollmentModel.UserDetails == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User details not supplied"));
            }

            var result = voiceItWrapper.deleteEnrollment(enrollmentModel.UserDetails.UserId,
                                                         enrollmentModel.UserDetails.Password, enrollmentModel.EnrollmentId);

            if (string.IsNullOrEmpty(result))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "The server did not respond back with a result"));
            }


            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Esempio n. 4
0
        public HttpResponseMessage CreateEnrollment(string userId, string pw, int clientId, long employeeUid, long departmentUid, [FromBody] byte[] voiceData)
        {
            var voiceItWrapper = new VoiceItWrapper();

            string result = string.Empty;

            result = voiceItWrapper.createEnrollmentByByteData(userId,
                                                               pw, voiceData);

            if (string.IsNullOrEmpty(result))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "The server did not respond back with a result"));
            }

            var enrollmentResponse = JsonConvert.DeserializeObject <EnrollmentResponse>(result);

            if (enrollmentResponse == null)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while deserializing response from voice auth server"));
            }

            string enrollmentResponseCode = enrollmentResponse.ResponseCode;

            if (enrollmentResponseCode == Constants.EnrollmentSuccessResponseCode)
            {
                var userVoiceManager = new UserVoiceManager();
                userVoiceManager.SaveUserVoiceData(new EmployeeEnrollment {
                    ClientId = clientId, EnrollmentId = enrollmentResponse.EnrollmentID, EmployeeUid = employeeUid, DepartmentUid = departmentUid
                });
                return(Request.CreateResponse(HttpStatusCode.OK, enrollmentResponse));
            }
            else if (Constants.EnrollmentErrorResponseCodes.ContainsKey(enrollmentResponseCode))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Constants.EnrollmentErrorResponseCodes[enrollmentResponseCode]));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }