public async Task <ActionResult> Create([Bind("AuthorID,Name,Address,City,State,PinCode,Email,Phone")] Author author)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(author);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Create([Bind("CategoryID,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Create([Bind("Title,ISBN,PublisherId,TotalCopies,AuthorId,CategoryId")] Book book)
        {
            if (ModelState.IsValid)
            {
                book.AvailableCopies = book.TotalCopies; //The number of available copies will initially be equal to the total copies of the book
                db.Books.Add(book);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.Authors    = new SelectList(db.Authors, "AuthorID", "Name");
            ViewBag.Categories = new SelectList(db.Categories, "CategoryID", "Name");
            ViewBag.Publishers = new SelectList(db.Publishers, "PublisherID", "Name");
            return(View());
        }
Exemplo n.º 4
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Request request = await db.Requests.SingleAsync(req => req.RequestID == id);

            db.Requests.Remove(request);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }