コード例 #1
0
        public ExportText GetExportCsvText(string userId)
        {
            ExportText exportText = new ExportText {
                Format = "text/plain"
            };

            User foundUser = _userDatabase.LoadedItems.FirstOrDefault(x => x.Id.ToString() == userId);

            if (foundUser == null)
            {
                return(exportText);
            }

            GeographyProvider geographyProvider;
            BooksReadProvider booksReadProvider;

            _books = new ObservableCollection <Book>();

            if (GetProviders(out geographyProvider, out booksReadProvider))
            {
                if (booksReadProvider.BooksRead != null && booksReadProvider.BooksRead.Any())
                {
                    List <BookRead> books =
                        booksReadProvider.BooksRead.Where(x => x.User == foundUser.Name).OrderBy(x => x.Date).ToList();

                    // Get the file export string
                    string formattedText;

                    BooksExporter.ExportToCsvFile(books, out formattedText);


                    // Return the formatted text
                    exportText.FormattedText = formattedText;
                }
            }

            return(exportText);
        }
コード例 #2
0
        public void WriteBooksToFile(string filename, List <BookRead> booksRead, out string formattedText)
        {
            BooksExporter.ExportToCsvFile(booksRead, out formattedText);

            WriteBooksToFile(filename, booksRead);
        }