示例#1
0
        public HttpResponseMessage GetInfo()
        {
            HostInfoResponse responseData = null;

            try
            {
                //Authenticate API key
                long?hostId = HostServices.GetCallerHostId();
                if (!hostId.HasValue)
                {
                    Log.Warn(ResponseMessages.InvalidAPIKey);
                    return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.InvalidAPIKey, ResponseMessages.InvalidAPIKey)));
                }

                //Perform transaction
                HostServices hostService = new HostServices();
                var          hostInfo    = hostService.GetHostInfoByAPIKey(RequestHeaders.API_KEY);

                responseData      = new HostInfoResponse();
                responseData.Info = hostInfo;

                //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)));
            }
        }