protected override object Convert(object value, Type targetType, object parameter) { if (!(value is long id)) { return(Binding.DoNothing); } if (id == 0) { return("[UNKNOWN]"); } //var bk = value as Book; //if (bk == null) return Binding.DoNothing; var to = Takeout.GetById(id); if (to == null) { return("[UNKNOWN]"); } var borrower = Borrower.GetById(to.BorrowerId); if (borrower == null) { return("[UNKNOWN]"); } return(borrower.Fullname.ToUpper()); }
protected override object Convert(object value, Type targetType, object parameter) { var id = (long)value; var n = Borrower.GetById(id)?.Fullname; if (UpperCase) { n = n?.ToUpper(); } return(n); }
private void CheckExpiration() { if (_checking) { return; } _checking = true; var expired = Takeout.Cache.Where(x => !x.IsReturned && IsExpired(x.TakeoutDate)).ToList(); foreach (var takeout in expired) { var notification = Notification.Cache.FirstOrDefault(x => x.NotificationType == Notification.NotificationTypes.TakeoutExpired && x.RecordId == takeout.Id); if (notification != null) { continue; } var borrower = Borrower.GetById(takeout.BorrowerId); var book = Book.GetById(takeout.BookId); notification = new Notification() { Thumbnail = book.Thumbnail, RecordId = takeout.Id, NotificationType = Notification.NotificationTypes.TakeoutExpired, Title = "BOOK NOT RETURNED", Message = $"{borrower.Fullname} did not return the book {book.Title} borrowed last {takeout.TakeoutDate.ToShortDateString()}." }; App.Current.Dispatcher.Invoke(() => notification.Save()); Messages.Enqueue(notification); Resources.chime_glass_note_hi.Play(); } _checking = false; }