Beispiel #1
0
        public IHttpActionResult PutNoteEdits(int id, NoteEdits noteEdits)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != noteEdits.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetNoteEdits(int id)
        {
            NoteEdits noteEdits = db.NoteEdits.Find(id);

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

            return(Ok(noteEdits));
        }
Beispiel #3
0
        public IHttpActionResult PostNoteEdits(NoteEdits noteEdits)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NoteEdits.Add(noteEdits);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = noteEdits.Id }, noteEdits));
        }
Beispiel #4
0
        public IHttpActionResult DeleteNoteEdits(int id)
        {
            NoteEdits noteEdits = db.NoteEdits.Find(id);

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

            db.NoteEdits.Remove(noteEdits);
            db.SaveChanges();

            return(Ok(noteEdits));
        }