コード例 #1
0
ファイル: Itemizing.cs プロジェクト: sq33G/Librarian
        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;
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
ファイル: LookingUp.cs プロジェクト: sq33G/Librarian
 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();
     }
 }
コード例 #7
0
ファイル: Publishing.cs プロジェクト: sq33G/Librarian
 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();
     }
 }
コード例 #8
0
ファイル: LookingUp.cs プロジェクト: sq33G/Librarian
 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();
     }
 }
コード例 #9
0
ファイル: Authoring.cs プロジェクト: sq33G/Librarian
 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();
     }
 }
コード例 #10
0
ファイル: Patronizing.cs プロジェクト: sq33G/Librarian
 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();
     }
 }
コード例 #11
0
ファイル: Publishing.cs プロジェクト: sq33G/Librarian
 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();
     }
 }
コード例 #12
0
 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();
     }
 }