public Borrow Borrow(Client client, LibraryItem item, double SalePrice, bool isInSale = false) { if (item.Amount <= 0) { throw new LibrarySystemException(); } if (client.IsBorrowing == true) { throw new LibrarySystemException(); } item.Amount--; client.IsBorrowing = true; if (isInSale) { if (client.Balance - SalePrice <= 0) { throw new LibrarySystemException(); } else { client.Balance -= SalePrice; } } else { if (client.Balance - item.Price < 0) { throw new LibrarySystemException(); } else { client.Balance -= item.Price; } } Borrow borrow = new Borrow(item, DateTime.Now, client.Id); _totalBorrows.Add(borrow); return(borrow); }
public void AddToclientsBorrows(Borrow borrow) { ClientsBorrows.Add(borrow); }