public List <StatistikBLL> SoldProperties(DateTime startdate, DateTime enddate) { StatistikDAL statistikdal = new StatistikDAL(); List <StatistikBLL> stats = statistikdal.SoldProperties(startdate, enddate); return(stats); //foreach (StatistikBLL stat in stats) // Console.WriteLine(stat.ToString()); //var output = statistik_solgteboliger_lbox; //output.Items.Add("Adresse\t\tPostnummer\tMægler\tPris\tHandelsdato"); //foreach (StatistikBLL stat in stats) // output.Items.Add(stat.ToString()); }
public static void StatsToText(DateTime startdate, DateTime enddate) { //DateTime salgsdato; //int price; //string broker; //string city; StatistikDAL StatistikDAL = new StatistikDAL(); List <StatistikBLL> statistik = StatistikDAL.SoldProperties(startdate, enddate); StreamWriter Stream = null; string path = @"Resources/Salgsoversigt.txt"; string a = $"\tTidsperiode: {startdate.ToShortDateString()} - {enddate.ToShortDateString()}"; string b = $"Adresse\t\tPostnummer\tMægler\tPris\tHandelsdato"; try { Stream = new StreamWriter(path); Stream.WriteLine(a); //tilføj tidsperiode man har sorteret efter Stream.WriteLine(b); foreach (StatistikBLL s in statistik) { Stream.WriteLine(s.ToString().PadRight(70)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (Stream != null) { Stream.Close(); } } }