public HttpResponseMessage SaveUserVoiceData(EmployeeEnrollment employeeEnrollment) { try { UserVoiceManager manager = new UserVoiceManager(); string result = string.Empty; result = manager.SaveUserVoiceData(employeeEnrollment); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (System.Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
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)); } }