Example #1
0
        public async Task <IHttpActionResult> PostBookWord(BookWord bookword)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BookWords.Add(bookword);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = bookword.Id }, bookword));
        }
Example #2
0
        public async Task <IHttpActionResult> DeleteBookWord(int id)
        {
            BookWord bookword = await db.BookWords.FindAsync(id);

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

            db.BookWords.Remove(bookword);
            await db.SaveChangesAsync();

            return(Ok(bookword));
        }