Ejemplo n.º 1
0
 public IActionResult Put(BucketBook book)
 {
     // Book check = db.Books.FirstOrDefault(x => x.BookID== book.BookID);
     if (ModelState.IsValid)
     {
         book.UserId = 3;
         // db.Books.Add(book);
         db.Update(book);
         db.BucketBooks.Update(book);
         db.SaveChanges();
         return(Ok(book));
     }
     return(BadRequest(ModelState));
 }
Ejemplo n.º 2
0
        public IActionResult Post(BucketBook book)
        {
            var bb = new BucketBook
            {
                Name   = book.Name, Author = book.Author, Description = book.Description, Price = book.Price, Count = book.Count,
                UserId = 3
            };

            // if (ModelState.IsValid)
            // {
            book.UserId = 3;
            db.BucketBooks.Add(new BucketBook
            {
                Name   = book.Name, Author = book.Author, Description = book.Description, Price = book.Price, Count = book.Count,
                UserId = 3
            });
            db.SaveChanges();
            return(Ok(book));

            // }

            return(BadRequest(ModelState));
        }
Ejemplo n.º 3
0
        public BucketBook Get(int id)
        {
            BucketBook product = db.BucketBooks.FirstOrDefault(x => x.BucketBookId == id);

            return(product);
        }