public IHttpActionResult PutClinicalNoteCategory(int id, ClinicalNoteCategory clinicalNoteCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != clinicalNoteCategory.ID)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClinicalNoteCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetClinicalNoteCategory(int id)
        {
            ClinicalNoteCategory clinicalNoteCategory = db.ClinicalNoteCategories.Find(id);

            if (clinicalNoteCategory == null)
            {
                return(NotFound());
            }

            return(Ok(clinicalNoteCategory));
        }
        public IHttpActionResult PostClinicalNoteCategory(ClinicalNoteCategory clinicalNoteCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ClinicalNoteCategories.Add(clinicalNoteCategory);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = clinicalNoteCategory.ID }, clinicalNoteCategory));
        }
        public IHttpActionResult DeleteClinicalNoteCategory(int id)
        {
            ClinicalNoteCategory clinicalNoteCategory = db.ClinicalNoteCategories.Find(id);

            if (clinicalNoteCategory == null)
            {
                return(NotFound());
            }

            db.ClinicalNoteCategories.Remove(clinicalNoteCategory);
            db.SaveChanges();

            return(Ok(clinicalNoteCategory));
        }
        private void FillDB()
        {
            try
            {
                if (db.ClinicalNotes.Count() > 0)
                {
                    return;
                }

                if (db.ClinicalNoteCategories.Count() <= 0)
                {
                    ClinicalNoteCategory cnc = new ClinicalNoteCategory();
                    cnc.Name          = "Cat1";
                    cnc.ComponentName = "Test";
                    cnc.FriendlyName  = "First Clinical Note";
                    db.ClinicalNoteCategories.Add(cnc);
                    db.SaveChanges();
                }

                ClinicalNote cn = new ClinicalNote();
                cn.CategoryID    = 1;
                cn.ParticipantID = 1;
                cn.DoctorID      = 1;
                cn.Created       = DateTime.Now.Date;
                cn.VisitDate     = DateTime.Now.Date;
                cn.Summary       = "This is a brief of the first note";
                cn.Data          = "{\"Brief\":\"This is a brief of the first note.\", \"Comments\":\"This is suppused to be a longer text, only used as a place-holder for the first test note.\"}";

                db.ClinicalNotes.Add(cn);

                cn               = new ClinicalNote();
                cn.CategoryID    = 1;
                cn.ParticipantID = 2;
                cn.DoctorID      = 2;
                cn.Created       = DateTime.Now.Date;
                cn.VisitDate     = DateTime.Now.Date;
                cn.Summary       = "This is a brief of the second note";
                cn.Data          = "{\"Brief\":\"This is a brief of the second note.\", \"Comments\":\"This is suppused to be a longer text, only used as a place-holder for the second test note.\"}";

                db.ClinicalNotes.Add(cn);

                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw;
            }
        }
        private void FillDB()
        {
            if (db.ClinicalNoteCategories.Count(e => e.Name == "Cat1") > 0)
            {
                return;
            }

            ClinicalNoteCategory cnc = new ClinicalNoteCategory();

            cnc.Name          = "Cat1";
            cnc.ComponentName = "ClinicalNoteTest";
            cnc.FriendlyName  = "First Clinical Note";

            db.ClinicalNoteCategories.Add(cnc);
            db.SaveChanges();
        }