public IHttpActionResult PostMessage(Message message)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Patient patient = db.Patients.Find(message.PatientId);
            if (patient == null)
            {
                return BadRequest("Patient with id " + message.PatientId + " does not exist.");
            }

            Doctor doctor = db.Doctors.Find(message.DoctorId);
            if (doctor == null)
            {
                return BadRequest("Doctor with id " + message.DoctorId + " does not exist.");
            }

            db.Messages.Add(message);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new {controller = "messages", id = message.MessageId}, message);
        }
        public IHttpActionResult PutMessage(int id, Message message)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != message.MessageId)
            {
                return BadRequest("The MessageId in the URL and the MessageId in the data do not match.");
            }

            Patient patient = db.Patients.Find(message.PatientId);
            if (patient == null)
            {
                return BadRequest("Patient with id " + message.PatientId + " does not exist.");
            }

            Doctor doctor = db.Doctors.Find(message.DoctorId);
            if (doctor == null)
            {
                return BadRequest("Doctor with id " + message.DoctorId + " does not exist.");
            }

            db.Entry(message).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MessageExists(id))
                {
                    return BadRequest("Message with id " + id + " does not exist.");
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new {controller = "messages", id = message.MessageId}, message);
        }