コード例 #1
0
        public HttpResponseMessage Get(long id)
        {
            PatientInfoPersistence pip         = new PatientInfoPersistence();
            PatientInfo            patientinfo = pip.GetPatient(id);

            if (patientinfo == null)
            {
                var       message = string.Format("Patient with id = {0} not found", id);
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.NotFound, err));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, patientinfo));
            }
        }
コード例 #2
0
        public HttpResponseMessage Post([FromBody] PatientInfo value)
        {
            PatientInfoPersistence pip = new PatientInfoPersistence();
            long id;

            // Save the patient in the db
            id = pip.SavePatientInfo(value);

            // Get the id of the created patient
            value.PatientId = id;

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);

            string msg = string.Format("Patient with id: {0} was created.", id);

            response = Request.CreateResponse(HttpStatusCode.OK, msg);

            return(response);
        }
コード例 #3
0
        public HttpResponseMessage Delete(long id)
        {
            PatientInfoPersistence pip = new PatientInfoPersistence();
            bool recordExisted         = false;

            recordExisted = pip.DeletePatient(id);

            HttpResponseMessage response;

            if (recordExisted)
            {
                string msg = string.Format("Patient with id: {0} was found and deleted.", id);
                response = Request.CreateResponse(HttpStatusCode.OK, msg);
            }
            else
            {
                var       message = string.Format("Patient with id = {0} was not found!", id);
                HttpError err     = new HttpError(message);
                response = Request.CreateResponse(HttpStatusCode.NotFound, err);
            }

            return(response);
        }
コード例 #4
0
        public ArrayList Get()
        {
            PatientInfoPersistence pip = new PatientInfoPersistence();

            return(pip.GetPatients());
        }