void IBookManager.Save(Book book) { if (book != null) { if (book.PublisherId != null) { //needed this way instead of getting via Publisher.Get() to be in same context var bookPublisher = db.Publishers.First(p => p.PublisherId == book.PublisherId); if (bookPublisher != null) { book.Publisher = bookPublisher; } } } if (book.BookId <= 0) { db.Books.Add(book); } else { db.Entry(book).State = EntityState.Modified; } db.Entry <Publisher>(book.Publisher).State = EntityState.Detached; db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "id,last_name,name,middle_name,age,address,phone")] Reader reader) { if (ModelState.IsValid) { db.Entry(reader).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reader)); }
public ActionResult Edit([Bind(Include = "ISBN,author,name,publication_type,tome,compiler,language,translator,place_publication,publishing,year,number,price")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(book)); }
public ActionResult Edit([Bind(Include = "id,knowledge1")] Knowledge knowledge) { if (ModelState.IsValid) { db.Entry(knowledge).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(knowledge)); }
public ActionResult Edit([Bind(Include = "id,FullName,age")] Authors authors) { if (ModelState.IsValid) { db.Entry(authors).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(authors)); }
public ActionResult CheckOut(CheckoutViewModel cvm) { if (ModelState.IsValid) { var checkoutEvent = new CheckoutEvent { DateTimeCheckedOut = cvm.TimeCheckedOut, BookId = cvm.BookId, PatronId = cvm.PatronId }; var book = db.Books.Single(x => x.BookId == cvm.BookId); book.PatronId = cvm.PatronId; db.CheckoutEvents.Add(checkoutEvent); db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cvm)); }
public ActionResult Edit([Bind(Include = "id,room,rack,shelf,existence,ISBN")] Instance instance) { if (ModelState.IsValid) { db.Entry(instance).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ISBN = new SelectList(db.Books, "ISBN", "name", instance.ISBN); return(View(instance)); }
public ActionResult Edit([Bind(Include = "ISBN,title,idAuthor,photo")] Books books) { if (ModelState.IsValid) { db.Entry(books).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idAuthor = new SelectList(db.Authors, "id", "FullName", books.idAuthor); return(View(books)); }
public ActionResult Edit([Bind(Include = "id,instance_id,reader_id,date_extradition,return_date")] Extradition extradition) { if (ModelState.IsValid) { db.Entry(extradition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.instance_id = new SelectList(db.Instances, "id", "existence", extradition.instance_id); ViewBag.reader_id = new SelectList(db.Readers, "id", "last_name", extradition.reader_id); return(View(extradition)); }
public void Save(Member member) { if (member.MemberId <= 0) { db.Members.Add(member); } else { db.Entry(member).State = EntityState.Modified; } db.SaveChanges(); }
public void Save(Author author) { if (author.AuthorId <= 0) { db.Authors.Add(author); } else { db.Entry(author).State = EntityState.Modified; } db.SaveChanges(); }