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");
                }
            }
        }
Example #2
0
        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");
            }
        }