private void updateDueDateInLendingList(Account account, ObservableCollection <BookToShow> renewBookList) { foreach (var book in renewBookList) { BookItem bookItem = dataLoadFromDB.findBookItemByID(int.Parse(book.Id)); if (bookItem.dueDate != null) { DateTime dateTime = (DateTime)bookItem.dueDate; bookItem.dueDate = dateTime.AddDays(10); } bookItem.lendingStatus = model.enums.LendingStatus.RENEWED; if (Db.getInstace().updateLendingRenew(CurrentMember.getInstance().GetAccount(), bookItem)) { if (dataLoadFromDB.updateBookItem(bookItem) != null) { returnUpdateBook(); returnUpdateMember(); } } else { MessageBox.Show("Unknow error"); } } }
private void removeSeletedItem() { BookToShow temp = SelectedItem; DataLoadFromDB data = DataLoadFromDB.getIntance(); MessageBoxResult dialogResult = MessageBox.Show("Ensure that you want to delete this item from member reserved list! It can't be undo", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (dialogResult == MessageBoxResult.OK) { ConfirmBooks.Remove(temp); BookItem tempBookItem = data.findBookItemByID(int.Parse(temp.Id)); CurrentMember current = CurrentMember.getInstance(); current.GetAccount().removeBookToReserveBookList(tempBookItem, "CANCELED"); } else { return; } }
private void addBookToLendingList(Account account, ObservableCollection <BookToShow> CheckOutBookList) { foreach (var book in CheckOutBookList) { BookItem bookItem = dataLoadFromDB.findBookItemByID(int.Parse(book.Id)); bookItem.lendingStatus = model.enums.LendingStatus.LOANED; bookItem.bordate = DateTime.Now; DateTime dateTime = (DateTime)bookItem.bordate; bookItem.dueDate = dateTime.AddDays(10); if (account.addNewBookToLendingList(bookItem) && account.removeBookToReserveBookList(bookItem, "COMPLETED")) { if (dataLoadFromDB.updateBookItem(bookItem) != null) { checkOutUpdateBook(); checkOutUpdateMember(); } else { MessageBox.Show("Unknow error"); } } } }