Пример #1
0
        private static void ImportJsonFile(string jsonFileName)
        {
            var dbContext = new ApplicationDbContext();
            IPropertiesService propertiesService = new PropertiesService(dbContext);

            var properties = JsonSerializer.Deserialize <IEnumerable <PropertyAsJson> >(File.ReadAllText(jsonFileName));

            foreach (var propertyJson in properties)
            {
                propertiesService.Add(propertyJson.District, propertyJson.Floor, propertyJson.TotalFloors, propertyJson.Size, propertyJson.YardSize, propertyJson.Year, propertyJson.Type, propertyJson.BuildingType, propertyJson.Price);
                Console.Write(".");
            }
        }
Пример #2
0
        public static void ImportJsonFile(string fileName)
        {
            var context = new ApplicationDbContext();
            IPropertiesService propertiesService = new PropertiesService(context);
            var properties = JsonSerializer.Deserialize <IEnumerable <PropertyAsJson> >(File.ReadAllText(fileName));

            foreach (var jsonProp in properties)
            {
                propertiesService.Add(jsonProp.District, jsonProp.Price, jsonProp.Floor,
                                      jsonProp.TotalFloors, jsonProp.Size, jsonProp.YardSize,
                                      jsonProp.Year, jsonProp.Type, jsonProp.BuildingType);
                Console.WriteLine(".");
            }
        }
Пример #3
0
        private static void ImportJsonFile(ApplicationDbContext dbContext, string jsonFileName)
        {
            IPropertiesService propertiesService = new PropertiesService(dbContext);

            var properties =
                JsonSerializer.Deserialize <IEnumerable
                                            <PropertyAsJson> >(File.ReadAllText(jsonFileName));

            foreach (var jsonProperty in properties)
            {
                propertiesService.Add(jsonProperty.District, jsonProperty.Price, jsonProperty.Floor, jsonProperty.TotalFloors, jsonProperty.Size, jsonProperty.YardSize, jsonProperty.Year, jsonProperty.Type, jsonProperty.BuildingType);
                Console.Write(".");
            }
        }
Пример #4
0
        private static void ImportJsonFile(string fileName)
        {
            var context           = new ApplicationDbContext();
            var propertiesService = new PropertiesService(context);

            var inputJson  = File.ReadAllText(fileName);
            var properties = JsonSerializer.Deserialize <IEnumerable <ImportPropertyDto> >(inputJson);

            foreach (var dto in properties)
            {
                propertiesService.Add(dto.Size, dto.YardSize, dto.Floor, dto.TotalFloors, dto.District, dto.Year,
                                      dto.Type, dto.BuildingType, dto.Price);
            }
        }
Пример #5
0
        //private static void HouseTagImporter()
        //{
        //    var context = new RealEstateContext();

        //    var houses = context.Properties.Where(x => x.PropertyType.Name == "Къща").ToList();

        //    foreach (var house in houses)
        //    {
        //        house.Tags.Clear();

        //        house.AddTag(new Tag(){Name = "Къща"});
        //    }
        //}

        private static void ImportJson(string jsonFile)
        {
            var context = new RealEstateContext();

            IPropertiesService service = new PropertiesService(context);

            var json = File.ReadAllText(jsonFile);

            var properties = JsonSerializer.Deserialize <IEnumerable <PropertyAsJson> >(json);

            foreach (var property in properties)
            {
                service.Add
                    (property.District, property.Price, property.Floor, property.TotalFloors, property.Size,
                    property.YardSize, property.Year, property.Type, property.BuildingType);
            }
        }
Пример #6
0
        public static void ImportJsonFile(string fileName)
        {
            var context = new RealEstatesDbContext();

            IPropertiesService propertiesService = new PropertiesService(context);

            var jsonConverter = JsonSerializer.Deserialize <IEnumerable <PropertyAsJson> >(
                File.ReadAllText(fileName));

            foreach (var item in jsonConverter)
            {
                propertiesService.Add(item.Size, item.YardSize, item.Floor,
                                      item.TotalFloors, item.District, item.Year,
                                      item.Type, item.BuildingType, item.Price);
                System.Console.Write("-");
            }
        }