Beispiel #1
0
        public void AddBill(int customerID, int amount, Borrow borrow)
        {
            using var context = new LibraryContext();
            var bill = new Bill();

            bill.CustumerID = customerID;
            bill.BillDate   = DateTime.Today;
            bill.Amount     = amount;
            bill.borrow     = borrow;
            context.Bills.Add(bill);
            context.SaveChanges();
        }
Beispiel #2
0
        public Customer GetCustomerByBorrow(Borrow borrow)
        {
            using var libraryContext = new LibraryContext();
            var borrows = (from b in libraryContext.Borrows
                           where b.BorrowID == borrow.BorrowID
                           select b).First();

            return((from c in libraryContext.Customers
                    join b in libraryContext.Borrows
                    on c.CustomerID equals b.CustomerID
                    where b.BorrowID == borrows.BorrowID
                    select c).FirstOrDefault());
        }
Beispiel #3
0
        public Borrow AddBorrow(int customerNumber, string bookTitle, DateTime borrowDate, DateTime returnDate)
        {
            using var libraryContext = new LibraryContext();
            var customer = (from c in libraryContext.Customers
                            where c.CustomerNumber == customerNumber
                            select c).First();

            var book = (from b in libraryContext.Books
                        where b.BookTitle == bookTitle
                        select b).First();

            var borrow = new Borrow();

            borrow.CustomerID = customer.CustomerID;
            borrow.BookID     = book.BookID;
            borrow.BorrowDate = borrowDate;
            borrow.ReturnDate = returnDate;
            libraryContext.Borrows.Add(borrow);
            libraryContext.SaveChanges();
            return(borrow);
        }
Beispiel #4
0
        public Book AddBook(string iSBNNumber, string bookTitle, string author, int purchaseYear, int price, int condition, Shelf shelf,
                            bool isBorrowed, Borrow borrow)
        {
            using var libraryContext = new LibraryContext();
            libraryContext.Borrows.Attach(borrow);
            var book = new Book();

            book.ISBNNumber   = iSBNNumber;
            book.BookTitle    = bookTitle;
            book.Author       = author;
            book.PurchaseYear = purchaseYear;
            book.Condition    = condition;
            book.Price        = price;
            book.ShelfID      = shelf.ShelfID;
            book.IsBorrowed   = isBorrowed;
            book.Borrows.Add(borrow);

            libraryContext.Books.Add(book);
            libraryContext.SaveChanges();
            return(book);
        }
Beispiel #5
0
 public void UpdateBorrowDate(Borrow borrow)
 {
     using var context   = new LibraryContext();
     borrow.DateOfBorrow = DateTime.Now;
     context.SaveChanges();
 }