예제 #1
0
        public Stream Vread(string type, string id, string vid)
        {
            IResourceHandler handler = _registry.GetHandler(type);

            if (handler == null)
            {
                return(ErrorMessage(HttpStatusCode.NotImplemented, String.Format("Get resource version of type {0} not implemented.", type)));
            }

            try
            {
                string payload = handler.VRead(id, vid);
                if (String.IsNullOrEmpty(payload))
                {
                    return(ErrorMessage(HttpStatusCode.NotFound, String.Format("Patient resource {0} / version {1} not found", id, vid)));
                }
                return(new MemoryStream(Encoding.UTF8.GetBytes(payload)));
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(NotImplementedException))
                {
                    return(ErrorMessage(HttpStatusCode.NotImplemented, e.Message));
                }
                return(ErrorMessage(HttpStatusCode.InternalServerError, e.Message));
            }
        }