Example #1
0
        private static void MoveEntity(ISession hb, DataClassesDataContext linq)
        {
            var helper = new DataResolveHelper(hb);

            helper.IdDictionaryMaps = _idDictionaryMaps;
            //IFlatService
            foreach (var l in linq.AppartmentForSales.Where(x => x.bActual.HasValue && x.bActual.Value))
            {
                var hbEntity = new Flat
                {
                    CreateDate        = l.DateOfAdd.HasValue ? l.DateOfAdd.Value : DateTime.Now,
                    DealVariant       = helper.ResolveHbEntity <DealVariant>(l.Variant),
                    Description       = l.vcComment,
                    District          = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.District>(l.District),
                    Floor             = l.iFloor,
                    FloorLevel        = null,
                    HasVideo          = l.bVideo ?? false,
                    KitchenSquare     = l.iKitchenArea,
                    Layout            = helper.ResolveHbEntity <Layout>(l.Planing),
                    Material          = helper.ResolveHbEntity <Material>(l.WallMatherial),
                    Ownership         = null,
                    Price             = l.iPrice,
                    Realtor           = helper.ResolveHbEntity <Realtor>(l.Rielter),
                    ResidentialSquare = l.iLivArea,
                    Street            = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.Street>(l.Street),
                    Terrace           = helper.ResolveHbEntity <Terrace>(l.Balcony),
                    TerritorialNumber = l.vcHouseNumber,
                    ToiletType        = helper.ResolveHbEntity <ToiletType>(l.SanUsel),
                    TotalFloor        = l.iFloors,
                    TotalRoomCount    = l.iRoomsAmount,
                    TotalSquare       = l.iAllArea
                };
                hb.SaveOrUpdate(hbEntity);
            }

            Console.WriteLine("Квартиры - готово");

            //IHouseService
            foreach (var l in linq.HousesForSales.Where(x => x.bActual.HasValue && x.bActual.Value))
            {
                var hbEntity = new House
                {
                    CreateDate        = l.DateOfAdd.HasValue ? l.DateOfAdd.Value : DateTime.Now,
                    DealVariant       = helper.ResolveHbEntity <DealVariant>(l.Variant),
                    Description       = l.vcComment,
                    District          = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.District>(l.District),
                    HasVideo          = l.bVideo ?? false,
                    Ownership         = null,
                    Price             = l.iPrice,
                    Realtor           = helper.ResolveHbEntity <Realtor>(l.Rielter),
                    Street            = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.Street>(l.Street),
                    TerritorialNumber = l.vcHouseNumber,
                    TotalFloor        = l.iFloors,
                    HouseSquare       = l.iHouseArea,
                    PlotSquare        = l.iLandArea,
                };
                hb.SaveOrUpdate(hbEntity);
            }

            Console.WriteLine("Дома - готово");

            //IPlotService
            foreach (var l in linq.HomestadForSales.Where(x => x.bActual.HasValue && x.bActual.Value))
            {
                var hbEntity = new Plot
                {
                    CreateDate        = l.DateOfAdd.HasValue ? l.DateOfAdd.Value : DateTime.Now,
                    DealVariant       = helper.ResolveHbEntity <DealVariant>(l.Variant),
                    Description       = l.vcComment,
                    District          = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.District>(l.District),
                    HasVideo          = l.bVideo ?? false,
                    Ownership         = null,
                    Price             = l.iPrice,
                    Realtor           = helper.ResolveHbEntity <Realtor>(l.Rielter),
                    Street            = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.Street>(l.Street),
                    TerritorialNumber = l.vcHouseNumber,
                    PlotSquare        = l.iArea
                };
                hb.SaveOrUpdate(hbEntity);
            }
            Console.WriteLine("Участки - готово");

            //IResidenceService
            foreach (var l in linq.PlacementForSales.Where(x => x.bActual.HasValue && x.bActual.Value))
            {
                var hbEntity = new Residence
                {
                    CreateDate        = l.DateOfAdd.HasValue ? l.DateOfAdd.Value : DateTime.Now,
                    DealVariant       = helper.ResolveHbEntity <DealVariant>(l.Variant),
                    Description       = l.vcComment,
                    District          = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.District>(l.District),
                    HasVideo          = l.bVideo ?? false,
                    Material          = helper.ResolveHbEntity <Material>(l.WallMatherial),
                    Ownership         = null,
                    Price             = l.iPrice,
                    Realtor           = helper.ResolveHbEntity <Realtor>(l.Rielter),
                    Street            = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.Street>(l.Street),
                    TerritorialNumber = l.vcHouseNumber,
                    TotalFloor        = l.iFloors,
                    Floor             = l.iFloor,
                    TotalSquare       = l.iPlaceArea
                };
                hb.SaveOrUpdate(hbEntity);
            }

            Console.WriteLine("Помещения - готово");

            //IRoomService
            foreach (var l in linq.RoomsForSales.Where(x => x.bActual.HasValue && x.bActual.Value))
            {
                var hbEntity = new Room
                {
                    CreateDate        = l.DateOfAdd.HasValue ? l.DateOfAdd.Value : DateTime.Now,
                    DealVariant       = helper.ResolveHbEntity <DealVariant>(l.Variant),
                    Description       = l.vcComment,
                    District          = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.District>(l.District),
                    HasVideo          = l.bVideo ?? false,
                    Material          = helper.ResolveHbEntity <Material>(l.WallMatherial),
                    Ownership         = null,
                    Price             = l.iPrice,
                    Realtor           = helper.ResolveHbEntity <Realtor>(l.Rielter),
                    Street            = helper.ResolveHbEntity <RealEstateDirectory.Domain.Entities.Dictionaries.Street>(l.Street),
                    TerritorialNumber = l.vcHouseNumber,
                    TotalFloor        = l.iFloors,
                    Floor             = l.iFloor,
                    FloorLevel        = null,
                    Layout            = helper.ResolveHbEntity <Layout>(l.Planing),
                    RoomCount         = l.iRoomsAmount,
                    TotalRoomCount    = l.iRoomsAll,
                    Terrace           = helper.ResolveHbEntity <Terrace>(l.Balcony),
                    TotalSquare       = l.iAllArea
                };
                hb.SaveOrUpdate(hbEntity);
            }

            Console.WriteLine("Комнаты - готово");
        }
Example #2
0
        private static void MoveDictionary(ISession hb, DataClassesDataContext linq)
        {
            //DealVariant
            _idDictionaryMaps.Add(typeof(DealVariant), new List <IdMap>());
            foreach (var curEnitie in linq.Variants)
            {
                var hbEntity = new DealVariant(curEnitie.vcVariant);
                AddMapForDictionary(curEnitie.idVariant, hb, hbEntity);
            }
            Console.WriteLine("Сделки - готово");

            //District
            _idDictionaryMaps.Add(typeof(RealEstateDirectory.Domain.Entities.Dictionaries.District), new List <IdMap>());
            foreach (var curEnitie in linq.Districts)
            {
                var hbEntity = new RealEstateDirectory.Domain.Entities.Dictionaries.District(curEnitie.vcDistrict);
                AddMapForDictionary(curEnitie.idDistrict, hb, hbEntity);
            }
            Console.WriteLine("Районы - готово");

            //Layout
            _idDictionaryMaps.Add(typeof(Layout), new List <IdMap>());
            foreach (var curEnitie in linq.Planings)
            {
                var hbEntity = new Layout(curEnitie.vcPlaning);
                AddMapForDictionary(curEnitie.idPlaning, hb, hbEntity);
            }
            Console.WriteLine("Планировки - готово");

            //Material
            _idDictionaryMaps.Add(typeof(Material), new List <IdMap>());
            foreach (var curEnitie in linq.WallMatherials)
            {
                var hbEntity = new Material(curEnitie.vcWallMatherial);
                AddMapForDictionary(curEnitie.idWallMatherial, hb, hbEntity);
            }
            Console.WriteLine("Материалы - готово");

            //Realtor
            _idDictionaryMaps.Add(typeof(Realtor), new List <IdMap>());
            foreach (var curEnitie in linq.Rielters)
            {
                var hbEntity = new Realtor(curEnitie.vcName, curEnitie.vcContacts);
                AddMapForDictionary(curEnitie.idRielter, hb, hbEntity);
            }
            Console.WriteLine("Риэлторы - готово");

            //Street
            _idDictionaryMaps.Add(typeof(RealEstateDirectory.Domain.Entities.Dictionaries.Street), new List <IdMap>());
            using (var helper = new DataResolveHelper(hb))
            {
                helper.IdDictionaryMaps = _idDictionaryMaps;
                foreach (var curEnitie in linq.Streets)
                {
                    if (curEnitie.idDistrict.HasValue)
                    {
                        var hbEntity    = new RealEstateDirectory.Domain.Entities.Dictionaries.Street(curEnitie.vcStreet);
                        var hDistrictId =
                            helper.ResolveHbId <RealEstateDirectory.Domain.Entities.Dictionaries.District>(curEnitie.idDistrict.Value);

                        var distictH = hb.Get <RealEstateDirectory.Domain.Entities.Dictionaries.District>(hDistrictId);
                        hbEntity.District = distictH;
                        AddMapForDictionary(curEnitie.idStreet, hb, hbEntity);
                    }
                }
                Console.WriteLine("Улицы - готово");
            }

            //Terrace
            _idDictionaryMaps.Add(typeof(Terrace), new List <IdMap>());
            foreach (var curEnitie in linq.Balconies)
            {
                var hbEntity = new Terrace(curEnitie.vcBalcony);
                AddMapForDictionary(curEnitie.idBalcony, hb, hbEntity);
            }
            Console.WriteLine("Балконы - готово");

            //ToiletType
            _idDictionaryMaps.Add(typeof(ToiletType), new List <IdMap>());
            foreach (var curEnitie in linq.SanUsels)
            {
                var hbEntity = new ToiletType(curEnitie.vcSanUsel);
                AddMapForDictionary(curEnitie.idSanUsel, hb, hbEntity);
            }
            Console.WriteLine("Сан узел - готово");

            //Агентства
            _idDictionaryMaps.Add(typeof(RealtorAgency), new List <IdMap>());
            foreach (var curEnitie in linq.Agencies)
            {
                var hbEntity = new RealtorAgency(curEnitie.vcName)
                {
                    Address     = curEnitie.vcAddress,
                    Contacts    = curEnitie.vcContacts,
                    Description = curEnitie.vcComments,
                    Director    = curEnitie.vcDirectorName
                };

                AddMapForDictionary(curEnitie.idAgency, hb, hbEntity);
            }
            Console.WriteLine("Агентства - готово");
        }