public void UpdateValuesFromModel()
 {
     District.MoveCurrentTo(DbEntity.District);
     if (DbEntity.District != null)
     {
         Street = new ListCollectionView((new[] { NullStreet }).Concat(DbEntity.District.Streets).ToList());
         Street.MoveCurrentTo(DbEntity.Street);
     }
     _Id        = DbEntity.Id;
     CreateDate = DbEntity.CreateDate;
     DealVariant.MoveCurrentTo(DbEntity.DealVariant);
     Condition.MoveCurrentTo(DbEntity.Condition);
     Description = DbEntity.Description;
     HasVideo    = DbEntity.HasVideo;
     Ownership.MoveCurrentTo(DbEntity.Ownership);
     Price = DbEntity.Price.HasValue ? DbEntity.Price.Value.ToString(NumberFormatInfo.CurrentInfo) : null;
     Realtor.MoveCurrentTo(DbEntity.Realtor);
     TerritorialNumber = DbEntity.TerritorialNumber;
     UpdateValuesFromConcreteModel();
 }
        private static void AddDicitonaryValue(bool addRealEstate = false)
        {
            var dealVariantEntityNew = new DealVariant("dealVariant1");

            if (dealVariantService.IsValid(dealVariantEntityNew))
            {
                dealVariantService.Save(dealVariantEntityNew);
            }

            var dealVariantEntityNew2 = new DealVariant("dealVariant2");

            if (dealVariantService.IsValid(dealVariantEntityNew2))
            {
                dealVariantService.Save(dealVariantEntityNew2);
            }
            var dealVariantEntityNew3 = new DealVariant("dealVariant2");

            if (dealVariantService.IsValid(dealVariantEntityNew3))
            {
                dealVariantService.Save(dealVariantEntityNew3);
            }

            var districtEntityNew = new District("district1");

            if (districtService.IsValid(districtEntityNew))
            {
                districtService.Save(districtEntityNew);
            }

            var districtEntityNew2 = new District("district2");

            if (districtService.IsValid(districtEntityNew2))
            {
                districtService.Save(districtEntityNew2);
            }
            var districtEntityNew3 = new District("district2");

            if (districtService.IsValid(districtEntityNew3))
            {
                districtService.Save(districtEntityNew3);
            }

            var floorLevelEntityNew = new FloorLevel("floorLevel1");

            if (floorLevelService.IsValid(floorLevelEntityNew))
            {
                floorLevelService.Save(floorLevelEntityNew);
            }

            var floorLevelEntityNew2 = new FloorLevel("floorLevel2");

            if (floorLevelService.IsValid(floorLevelEntityNew2))
            {
                floorLevelService.Save(floorLevelEntityNew2);
            }
            var floorLevelEntityNew3 = new FloorLevel("floorLevel2");

            if (floorLevelService.IsValid(floorLevelEntityNew3))
            {
                floorLevelService.Save(floorLevelEntityNew3);
            }

            var layoutEntityNew = new Layout("layout1");

            if (layoutService.IsValid(layoutEntityNew))
            {
                layoutService.Save(layoutEntityNew);
            }

            var layoutEntityNew2 = new Layout("layout2");

            if (layoutService.IsValid(layoutEntityNew2))
            {
                layoutService.Save(layoutEntityNew2);
            }
            var layoutEntityNew3 = new Layout("layout2");

            if (layoutService.IsValid(layoutEntityNew3))
            {
                layoutService.Save(layoutEntityNew3);
            }

            var materialEntityNew = new Material("material1");

            if (materialService.IsValid(materialEntityNew))
            {
                materialService.Save(materialEntityNew);
            }

            var materialEntityNew2 = new Material("material2");

            if (materialService.IsValid(materialEntityNew2))
            {
                materialService.Save(materialEntityNew2);
            }
            var materialEntityNew3 = new Material("material2");

            if (materialService.IsValid(materialEntityNew3))
            {
                materialService.Save(materialEntityNew3);
            }

            var ownershipEntityNew = new Ownership("ownership1");

            if (ownershipService.IsValid(ownershipEntityNew))
            {
                ownershipService.Save(ownershipEntityNew);
            }

            var ownershipEntityNew2 = new Ownership("ownership2");

            if (ownershipService.IsValid(ownershipEntityNew2))
            {
                ownershipService.Save(ownershipEntityNew2);
            }
            var ownershipEntityNew3 = new Ownership("ownership2");

            if (ownershipService.IsValid(ownershipEntityNew3))
            {
                ownershipService.Save(ownershipEntityNew3);
            }

            var realtorEntityNew = new Realtor("realtor1", "phone");

            if (realtorService.IsValid(realtorEntityNew))
            {
                realtorService.Save(realtorEntityNew);
            }

            var realtorEntityNew2 = new Realtor("realtor2", "phone");

            if (realtorService.IsValid(realtorEntityNew2))
            {
                realtorService.Save(realtorEntityNew2);
            }
            var realtorEntityNew3 = new Realtor("realtor2", "phone");

            if (realtorService.IsValid(realtorEntityNew3))
            {
                realtorService.Save(realtorEntityNew3);
            }

            var sewageEntityNew = new Sewage("sewage1");

            if (sewageService.IsValid(sewageEntityNew))
            {
                sewageService.Save(sewageEntityNew);
            }

            var sewageEntityNew2 = new Sewage("sewage2");

            if (sewageService.IsValid(sewageEntityNew2))
            {
                sewageService.Save(sewageEntityNew2);
            }
            var sewageEntityNew3 = new Sewage("sewage2");

            if (sewageService.IsValid(sewageEntityNew3))
            {
                sewageService.Save(sewageEntityNew3);
            }

            var streetEntityNew = new Street("street1");

            if (streetService.IsValid(streetEntityNew))
            {
                districtEntityNew.AddStreet(streetEntityNew);
                districtService.Save(districtEntityNew);
            }

            var streetEntityNew1 = new Street("street11");

            if (streetService.IsValid(streetEntityNew1))
            {
                districtEntityNew.AddStreet(streetEntityNew1);
                districtService.Save(districtEntityNew);
            }

            var streetEntityNew2 = new Street("street2");

            if (streetService.IsValid(streetEntityNew2))
            {
                districtEntityNew2.AddStreet(streetEntityNew2);
                streetService.Save(streetEntityNew);
            }

            var streetEntityNew3 = new Street("street2");

            if (streetService.IsValid(streetEntityNew3))
            {
                Debug.Assert(false, "Не должан была пройти валидация.");
            }

            var terraceEntityNew = new Terrace("terrace1");

            if (terraceService.IsValid(terraceEntityNew))
            {
                terraceService.Save(terraceEntityNew);
            }

            var terraceEntityNew2 = new Terrace("terrace2");

            if (terraceService.IsValid(terraceEntityNew2))
            {
                terraceService.Save(terraceEntityNew2);
            }
            var terraceEntityNew3 = new Terrace("terrace2");

            if (terraceService.IsValid(terraceEntityNew3))
            {
                terraceService.Save(terraceEntityNew3);
            }

            var toiletTypeEntityNew = new ToiletType("toiletType1");

            if (toiletTypeService.IsValid(toiletTypeEntityNew))
            {
                toiletTypeService.Save(toiletTypeEntityNew);
            }

            var toiletTypeEntityNew2 = new ToiletType("toiletType2");

            if (toiletTypeService.IsValid(toiletTypeEntityNew2))
            {
                toiletTypeService.Save(toiletTypeEntityNew2);
            }
            var toiletTypeEntityNew3 = new ToiletType("toiletType2");

            if (toiletTypeService.IsValid(toiletTypeEntityNew3))
            {
                toiletTypeService.Save(toiletTypeEntityNew3);
            }

            var waterSupplyEntityNew = new WaterSupply("waterSupply1");

            if (waterSupplyService.IsValid(waterSupplyEntityNew))
            {
                waterSupplyService.Save(waterSupplyEntityNew);
            }

            var waterSupplyEntityNew2 = new WaterSupply("waterSupply2");

            if (waterSupplyService.IsValid(waterSupplyEntityNew2))
            {
                waterSupplyService.Save(waterSupplyEntityNew2);
            }
            var waterSupplyEntityNew3 = new WaterSupply("waterSupply2");

            if (waterSupplyService.IsValid(waterSupplyEntityNew3))
            {
                waterSupplyService.Save(waterSupplyEntityNew3);
            }
            if (!addRealEstate)
            {
                return;
            }

            var flat = new Flat
            {
                DealVariant       = dealVariantEntityNew,
                Description       = "decr",
                District          = districtEntityNew,
                Floor             = 3,
                FloorLevel        = floorLevelEntityNew,
                HasVideo          = true,
                KitchenSquare     = 32,
                Layout            = layoutEntityNew,
                Material          = materialEntityNew,
                Ownership         = ownershipEntityNew,
                Price             = 32323,
                Realtor           = realtorEntityNew,
                ResidentialSquare = 323,
                Street            = streetEntityNew,
                SubmitToDomino    = false,
                SubmitToVDV       = true,
                Terrace           = terraceEntityNew,
                TerritorialNumber = "32a",
                ToiletType        = toiletTypeEntityNew,
                TotalFloor        = 32,
                TotalRoomCount    = 5,
                TotalSquare       = 323
            };

            if (flatService.IsValid(flat))
            {
                flatService.Save(flat);
            }

            var room = new Room
            {
                DealVariant       = dealVariantEntityNew,
                Description       = "decr",
                District          = districtEntityNew,
                Floor             = 3,
                FloorLevel        = floorLevelEntityNew,
                HasVideo          = true,
                Layout            = layoutEntityNew,
                Material          = materialEntityNew,
                Ownership         = ownershipEntityNew,
                Price             = 32323,
                Realtor           = realtorEntityNew,
                Street            = streetEntityNew,
                SubmitToDomino    = false,
                SubmitToVDV       = true,
                Terrace           = terraceEntityNew,
                TerritorialNumber = "32a",
                TotalFloor        = 32,
                TotalRoomCount    = 5,
                TotalSquare       = 323,
                RoomCount         = 2
            };

            if (roomService.IsValid(room))
            {
                roomService.Save(room);
            }

            var residence = new Residence
            {
                DealVariant       = dealVariantEntityNew,
                Description       = "decr",
                District          = districtEntityNew,
                Floor             = 3,
                HasVideo          = true,
                Material          = materialEntityNew,
                Ownership         = ownershipEntityNew,
                Price             = 32323,
                Realtor           = realtorEntityNew,
                Street            = streetEntityNew,
                SubmitToDomino    = false,
                SubmitToVDV       = true,
                TerritorialNumber = "32a",
                TotalFloor        = 32,
                TotalSquare       = 323
            };

            if (residenceService.IsValid(residence))
            {
                residenceService.Save(residence);
            }

            var house = new House
            {
                DealVariant       = dealVariantEntityNew,
                Description       = "decr",
                District          = districtEntityNew,
                HasVideo          = true,
                Material          = materialEntityNew,
                Ownership         = ownershipEntityNew,
                Price             = 32323,
                Realtor           = realtorEntityNew,
                Street            = streetEntityNew,
                SubmitToDomino    = false,
                SubmitToVDV       = true,
                TerritorialNumber = "32a",
                TotalFloor        = 32,
                HasBathhouse      = true,
                HasGarage         = true,
                HasGas            = true,
                HouseSquare       = 342,
                PlotSquare        = 123,
                Sewage            = sewageEntityNew,
                WaterSupply       = waterSupplyEntityNew
            };

            if (houseService.IsValid(house))
            {
                houseService.Save(house);
            }
            var plot = new Plot
            {
                DealVariant       = dealVariantEntityNew,
                Description       = "decr",
                District          = districtEntityNew,
                HasVideo          = true,
                Ownership         = ownershipEntityNew,
                Price             = 32323,
                Realtor           = realtorEntityNew,
                Street            = streetEntityNew,
                SubmitToDomino    = false,
                SubmitToVDV       = true,
                TerritorialNumber = "32a",
                PlotSquare        = 123
            };

            if (plotService.IsValid(plot))
            {
                plotService.Save(plot);
            }
        }
Пример #3
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("Агентства - готово");
        }
Пример #4
0
 public bool IsPossibleToDeleteDealVariant(DealVariant entity)
 {
     return(CurrentSession.Query <RealEstate>().Count(x => x.DealVariant == entity) == 0);
 }