private XCollection<Book> getExpireBooks(XCollection<Book> books, DateTime nextBookTime)
 {
     var booksToExpire = new XCollection<Book>();
     books.ForEach(book =>
     {
         if (!string.IsNullOrEmpty(book.ExpiredDateStr) &&
             !book.IsExpiredBook &&
             book.ExpiredDate == nextBookTime)
         {
             booksToExpire.Add(book);
         }
     });
     return booksToExpire;
 }
        private async void CheckExpiration(XCollection<Book> booksToExpire)
        {
            if(Debugger.IsAttached) Debug.WriteLine("CheckExpirationDoing");
            var messageStr = new StringBuilder();

            foreach (var book in booksToExpire)
            {
                Notify(book);
             
                await _bookProvider.RemoveFullBookInLocalStorage(book);
                book.IsExpiredBook = true;
                
                messageStr.AppendLine(book.Description.Hidden.TitleInfo.BookTitle);
            }
            
            await _catalogProvider.ExpireBooks(booksToExpire);

            var books = await _catalogProvider.GetMyBooksFromCache(CancellationToken.None);
            if (books == null) books = booksToExpire;            
            else
            {
                booksToExpire.ForEach(expiredBook =>
                {
                    try
                    {
                        var bk = books.First(book => book.Id == expiredBook.Id);
                        bk.IsExpiredBook = true;
                    }
                    catch (Exception){}
                });
            }            

            _catalogProvider.SaveMyBooksToCache(books, CancellationToken.None);
            _catalogProvider.CheckBooks();

            if (messageStr.Length > 0) { 
                //Deployment.Current.Dispatcher.BeginInvoke(() =>
                //{
                //    MessageBox.Show(messageStr.ToString(), "Книги истекли", MessageBoxButton.OK);
                //});

                await new MessageDialog(messageStr.ToString(), "Книги истекли").ShowAsync();
            }
            var purchaseService = ((Digillect.Mvvm.UI.WindowsRTApplication)Application.Current).Scope.Resolve<IPurchaseServiceDecorator>();
            foreach (var bk in booksToExpire)
            {
                await purchaseService.RefreshPages(bk);
            }

            if(NextExpireDateTime(books) != DateTime.MaxValue) StartGuardian();
        }
        private DateTime NextExpireDateTime(XCollection<Book> books)
        {
            var nextBookTime = DateTime.MaxValue;

            books.ForEach(book =>
            {
                if (!string.IsNullOrEmpty(book.ExpiredDateStr) && !book.IsExpiredBook && book.ExpiredDate < nextBookTime)
                {
                    nextBookTime = book.ExpiredDate;
                }
            });

            return nextBookTime;
        }