public HttpResponseMessage CreateHost(CreateHostRequest request) { CreateHostResponse responseData = null; string newAPIKey = null; try { //Validate input if (request == null || string.IsNullOrEmpty(request.Name)) { return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.InvalidParam, ResponseMessages.InvalidParam))); } //Perform transaction HostServices hostService = new HostServices(); hostService.CreateHost(request, out newAPIKey); responseData = new CreateHostResponse(); responseData.APIKey = newAPIKey; //Send response return(Request.CreateResponse(new GenericResponse(responseData, ResponseCodes.Success, ResponseMessages.Success))); } catch (Exception ex) { Log.Exception(ex); return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.Error, ResponseMessages.Error))); } }