// BEGIN Static Builders private static Klib.Book Build(Book book) { var builtBook = new Klib.Book(); builtBook.UID = book.UID; builtBook.Title = book.Title; builtBook.Author = book.Author; builtBook.ISBN10 = book.ISBN10; builtBook.ISBN13 = book.ISBN13; builtBook.UniqueMap = book.UniqueMap; builtBook.Owner = book.Owner; return builtBook; }
private static void Write(Book book) { // For writing new book and updating exisitng book var newBook = new Klib.Book(); var existingBookCount = db.Books .Select(thisBook => thisBook.UID == book.UID) .Count(); if (existingBookCount == 0) { int resourceUID = WriteResource(); newBook.UID = resourceUID; } else newBook = Build(book); db.Books.InsertOnSubmit(newBook); db.SubmitChanges(); }