public void Update([DataBind("publisher")] Publisher formpublisher, int[] bookids, String[] booknames, String[] bookauthors) { Publisher publisher = Publisher.Find(formpublisher.Id); publisher.Name = formpublisher.Name; IDictionary books = new Hashtable(); int index = 0; foreach(int id in bookids) { Book book = new Book(); book.Id = id; book.Name = booknames[index]; book.Author = bookauthors[index]; books[id] = book; index++; } foreach(Book book in publisher.Books) { Book formBook = books[book.Id] as Book; book.Name = formBook.Name; book.Author = formBook.Author; book.Save(); } publisher.Save(); Flash["message"] = "Changes saved"; RedirectToAction("EditPublisher", "publisherId=" + publisher.Id); }