private static void MostExpensiveDistricts(ApplicationDbContext db) { Console.Write("Districts count:"); int count = int.Parse(Console.ReadLine()); IDistrictsService districtsService = new DistrictsService(db); var districts = districtsService.GetMostExpensiveDistricts(count); foreach (var district in districts) { Console.WriteLine($"{district.Name} => {district.AveragePricePerSquareMeter:0.00}€/m² ({district.PropertiesCount})"); } }
private static void MostExpensiveDistricts(RealEstatesDbContext context) { Console.Write("Districts count:"); var count = int.Parse(Console.ReadLine()); var service = new DistrictsService(context); var districts = service.GetMostExpensiveDistricts(count); var serializer = new XmlSerializer(typeof(List <DistrictInfoDto>), new XmlRootAttribute("Districts")); var namespacesSettings = new XmlSerializerNamespaces(); namespacesSettings.Add("", ""); var textWriter = new StringWriter(); serializer.Serialize(textWriter, districts, namespacesSettings); Console.WriteLine(textWriter.ToString().TrimEnd()); }