static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var db = new RealEstateDbContext(); db.Database.Migrate(); IPropertiesService propertiesService = new PropertiesService(db); Console.Write("Min. Price: "); int minPrice = int.Parse(Console.ReadLine()); Console.Write("Max. Price: "); int maxPrice = int.Parse(Console.ReadLine()); var properties = propertiesService.SearchByPrice(minPrice, maxPrice); foreach (var property in properties) { Console.WriteLine($"{property.District}, fl.{property.Floor}, {property.Size} m², {property.Year}, {property.Price} €, {property.PropertyType}, {property.BuildingType}"); } Console.WriteLine(new string('-', 60)); IDistrictsService districtsService = new DistrictsService(db); var districts = districtsService.GetTopDistrictsByAveragePrice(100); foreach (var district in districts) { Console.WriteLine($"{district.Name} => Price:{district.AveragePrice:0.00} ({district.MinPrice}-{district.MinPrice}) => {district.PropertiesCount} properties"); } }
public static void Main(string[] args) { var db = new RealEstateDbContext(); using (db) { db.Database.Migrate(); IPropertiesService propertiesService = new PropertiesService(db); //propertiesService.Create("Dianabad", "5-Rooms", "Brick", 2019, 210000, 100, 5, 12); //propertiesService.UpdateTags(2); //propertiesService.UpdateTags(3); IDistrictsService districtsService = new DistrictsService(db); var districts = districtsService.GetTopDistrictsByAveragePrice(); foreach (var district in districts) { Console.WriteLine($"{district.Name} => {district.AveragePrice:f2} ({district.MinPrice} - {district.MaxPrice}) => {district.PropertiesCount} properties"); } } }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var db = new RealEstateDbContext(); //db.Database.Migrate(); IPropertiesService propertiesService = new PropertiesService(db); //propertiesService.Create("Dianabad", 100, 2019, 322000000, "4-Staen", "Panelka", 17, 21); IDistrictsService districtsService = new DistrictsService(db); //var districts = districtsService.GetTopDisctrictsByAveragePrice(); //foreach (var district in districts) //{ // Console.WriteLine($"{district.Name} => Price: {district.AveragePrice} ({district.MinPrice} - {district.MaxPrice}) => properties: {district.PropertiesCount}"); //} Console.Write("Min price: "); int minPrice = int.Parse(Console.ReadLine()); Console.Write("Max price: "); int maxPrice = int.Parse(Console.ReadLine()); var properties = propertiesService.SearchByPrice(minPrice, maxPrice); foreach (var property in properties) { Console.WriteLine($"{property.Price}"); } }
public static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var context = new ApplicationDbContext(); context.Database.Migrate(); IPropertiesService propertiesService = new PropertiesService(context); IDistrictsService districtsService = new DistrictsService(context); while (true) { Console.Clear(); Console.WriteLine($"Choose an option:"); Console.WriteLine($"1. Property search by price and size:"); Console.WriteLine($"2. Property search by price:"); Console.WriteLine($"3. Most expensive districts:"); Console.WriteLine($"4. Average price per square meter:"); Console.WriteLine($"0. Exit"); var input = Console.ReadLine(); var hasOption = int.TryParse(input, out int option); if (hasOption && option == 0) { return; } if (hasOption && option >= 1 && option <= 4) { switch (option) { case 1: PropertySearchByPriceAndSize(propertiesService); break; case 2: PropertySearchByPrice(propertiesService); break; case 3: MostExpensiveDistricts(districtsService); break; case 4: AveragePricePerSquareMeter(propertiesService); break; } } Console.WriteLine($"Press any key to continue:"); Console.ReadKey(); } }
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 SearchMostExpensiveDistricts(RealEstatesDbContext context) { Console.WriteLine("Press districts count:"); int count = int.Parse(Console.ReadLine()); IDistrictsService districtsService = new DistrictsService(context); var districts = districtsService.MostExpensiveDistricts(count); var writer = new StringWriter(); var serializer = new XmlSerializer(typeof(DistrictInfoDTO[]), new XmlRootAttribute("Districts")); serializer.Serialize(writer, districts); Console.WriteLine(writer.ToString()); writer.Close(); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; RealEstatesDbContext db = new RealEstatesDbContext(); db.Database.Migrate(); var propService = new PropertiesService(db); //Console.Write("Min year:"); //var minYear = int.Parse(Console.ReadLine()); //Console.Write("Max year:"); //var maxYear = int.Parse(Console.ReadLine()); //Console.Write("Min size:"); //var minSize = int.Parse(Console.ReadLine()); //Console.Write("Max size:"); //var maxSize = int.Parse(Console.ReadLine()); //var properties = propService.Search(minYear, maxYear, minSize, maxSize); //Console.Write("Min price:"); //var minPrice = int.Parse(Console.ReadLine()); //Console.Write("Max price:"); //var maxPrice = int.Parse(Console.ReadLine()); //var sortedPropsByPrice = propService.SearchByPrice(minPrice, maxPrice); //foreach (var prop in sortedPropsByPrice) //{ // Console.WriteLine($"{prop.DistrictName} => {prop.Year} - {prop.Size}m2 Type: {prop.PropertyType} Floor: {prop.Floor} Price: {prop.Price}€"); //} var districtsService = new DistrictsService(db); var districts = districtsService.GetTopDistrictByPropertiesCount(15); foreach (var d in districts) { Console.WriteLine($"{d.Name} [{d.MinPrice:F2} - {d.MaxPrice:F2}] -> {d.AveragePrice:F2} ==> {d.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()); }
public DistrictsController(KWMContext context, DistrictsService districtsService) { _context = context; _districtsService = districtsService; }
public DistrictsControllerManager() { DistrictsService = new DistrictsService(); }