public ActionResult Post([FromBody] Book book)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     db.Books.Add(book);
     db.SaveChanges();
     return(CreatedAtAction("Post", book));
 }
 public ActionResult Post([FromBody] Author author)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     db.Authors.Add(author);
     db.SaveChanges();
     return(CreatedAtAction("Post", author));
 }
Esempio n. 3
0
 public ActionResult Post([FromBody] Publisher publisher)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     db.Publishers.Add(publisher);
     db.SaveChanges();
     return(CreatedAtAction("Post", publisher));
 }
 public ActionResult Post([FromBody] Category category)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     db.Categories.Add(category);
     db.SaveChanges();
     return(CreatedAtAction("Post", category));
 }
        public ActionResult Create([Bind(Include = "id,publish_name,company_name,address,postal_code,country")] Publisher publisher)
        {
            if (ModelState.IsValid)
            {
                db.Publishers.Add(publisher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(publisher));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "id,name,email,address")] Author author)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(author);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "id,name")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "id,ISBN,title,category_id,publisher_id,publish_date,author_id,prise,url")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.author_id    = new SelectList(db.Authors, "id", "name", book.author_id);
            ViewBag.category_id  = new SelectList(db.Categories, "id", "name", book.category_id);
            ViewBag.publisher_id = new SelectList(db.Publishers, "id", "publish_name", book.publisher_id);
            return(View(book));
        }