public HttpResponseMessage ReadOID(int idCommand) { // CAD, CEN, EN, returnValue CommandRESTCAD commandRESTCAD = null; CommandCEN commandCEN = null; CommandEN commandEN = null; CommandDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); commandRESTCAD = new CommandRESTCAD(session); commandCEN = new CommandCEN(commandRESTCAD); // Data commandEN = commandCEN.ReadOID(idCommand); // Convert return if (commandEN != null) { returnValue = CommandAssembler.Convert(commandEN, session); } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 404 - Not found if (returnValue == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }