public static Item GetItem(long id) { using (LibraryDataContext ctx = new LibraryDataContext()) { Item found = ctx.Items.Find(id); ctx.Entry(found).Collection(item => item.Authors).Load(); ctx.Entry(found).Collection(item => item.Editions).Load(); foreach (Edition ed in found.Editions) ctx.Entry(ed).Collection(edi => edi.Copies).Load(); ctx.Entry(found).Collection(item => item.ItemSubjects).Load(); ctx.Entry(found).Collection(item => item.Reserves).Load(); return found; } }
public async Task <IActionResult> PutBook(int id, Book book) { if (id != book.Id) { return(BadRequest()); } _context.Entry(book).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTransaction(int id, Transaction transaction) { if (id != transaction.TransactionId) { return(BadRequest()); } _context.Entry(transaction).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static Item GetItem(long id) { using (LibraryDataContext ctx = new LibraryDataContext()) { Item found = ctx.Items.Find(id); ctx.Entry(found).Collection(item => item.Authors).Load(); ctx.Entry(found).Collection(item => item.Editions).Load(); foreach (Edition ed in found.Editions) { ctx.Entry(ed).Collection(edi => edi.Copies).Load(); } ctx.Entry(found).Collection(item => item.ItemSubjects).Load(); ctx.Entry(found).Collection(item => item.Reserves).Load(); return(found); } }
public static void UpdatePatron(Patron patron) { using (LibraryDataContext ctx = new LibraryDataContext()) { ctx.Patrons.Attach(patron); ctx.Entry(patron).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public static void Delete(Lookup lookup) { using (LibraryDataContext ctx = new LibraryDataContext()) { ctx.Lookups.Attach(lookup); ctx.Entry(lookup).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } }
public static void UpdatePublisher(Publisher persistentPublisher) { using (LibraryDataContext ctx = new LibraryDataContext()) { ctx.Publishers.Attach(persistentPublisher); ctx.Entry(persistentPublisher).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public static void Update(Lookup lookup) { using (LibraryDataContext ctx = new LibraryDataContext()) { ctx.Lookups.Attach(lookup); ctx.Entry(lookup).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public static void UpdateAuthor(Author author) { using (Data.LibraryDataContext ctx = new LibraryDataContext()) { ctx.Authors.Attach(author); ctx.Entry(author).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }