Beispiel #1
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Biography")] Author author)
 {
     if (ModelState.IsValid)
     {
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "ISBN,Title,PublishedYear,Price,Count,AuthorId")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AuthorId = new SelectList(db.Authors, "Id", "FirstName", book.AuthorId);
     return(View(book));
 }
        public async Task <ActionResult> Edit([Bind(Include = "MemberId,FullName,PostalCode")] Member member)
        {
            if (ModelState.IsValid)
            {
                db.Entry(member).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(member));
        }
Beispiel #4
0
        public async Task <ActionResult> Edit([Bind(Include = "LibraryBookSId,MemberId,WhenSignedOut,WhenReturned")] BookSignedOut bookSignedOut)
        {
            /*
             * 4. The member can return a book
             */

            db.Entry(bookSignedOut).State = EntityState.Modified;
            bookSignedOut.WhenReturned    = DateTime.Now;
            await db.SaveChangesAsync();

            return(RedirectToAction("List", new { id = bookSignedOut.LibraryBookSId }));
        }
        public IHttpActionResult PutBooks(int id, Books books)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            var dbBook = db.Books.Find(books.Id);

            dbBook.Title     = books.Title;
            dbBook.Published = books.Published;
            dbBook.Language  = books.Language;
            dbBook.Genre     = books.Genre;

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutAuthors(int id, Authors authors)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            var dbAuthor = db.Authors.Find(authors.Id);

            dbAuthor.FirstName = authors.FirstName;
            dbAuthor.LastName  = authors.LastName;
            dbAuthor.Country   = authors.Country;

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }