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); }
public void WriteBooksToFile(string filename, List <BookRead> booksRead, out string formattedText) { BooksExporter.ExportToCsvFile(booksRead, out formattedText); WriteBooksToFile(filename, booksRead); }