public bool Borrow(Loan loan)
        {
            Book book = this.context.Books.Select(x => x).Where(y => y.ISBN == loan.BookISBN).Take(1).FirstOrDefault();
            try
            {
                if (book != null && this.context.Books.Contains(book))
                {
                    book.Copies -= 1;
                }
                else
                {
                    throw new ArgumentException("Book does not exist!");
                }

                this.context.Loans.InsertOnSubmit(loan);
                loan.User.TakenBooks += 1;
                this.context.SubmitChanges();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
                return false;
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                return false;
            }

            return true;
        }
        public bool Return(Loan loan)
        {
            History loanHistory = new History
            {
                UserId = loan.UserId,
                BookISBN = loan.BookISBN,
                LeantDate = loan.LeantDate,
                ReturnDate = loan.ExpectedReturnDate
            };

            Book returnedBook = this.context.Books.Select(x => x).Where(y => y.ISBN == loan.BookISBN).Take(1).FirstOrDefault();

            try
            {
                if (returnedBook != null)
                {
                    returnedBook.Copies += 1;
                }
                else
                {
                    throw new ArgumentException("You tried to return a book that is no in the library!");
                }
                this.context.Histories.InsertOnSubmit(loanHistory);
                this.context.Loans.DeleteOnSubmit(loan);
                loan.User.TakenBooks -= 1;
                this.context.SubmitChanges();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
                return false;
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                return false;
            }

            return true;
        }
		private void detach_Loans(Loan entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
		private void attach_Loans(Loan entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}
 partial void DeleteLoan(Loan instance);
 partial void UpdateLoan(Loan instance);
 partial void InsertLoan(Loan instance);