Ejemplo n.º 1
0
        public IEnumerable <PropertyDTO> SelectByPartner(Guid partner)
        {
            CountryRepository  countryRepository  = new CountryRepository(Connector);
            DistrictRepository districtRepository = new DistrictRepository(Connector);
            PropertyFeatureDetailRepository featureDetailRepository = new PropertyFeatureDetailRepository(Connector);
            PropertyPictureRepository       pictureRepository       = new PropertyPictureRepository(Connector);
            PropertyTypeRepository          propertyTypeRepository  = new PropertyTypeRepository(Connector);
            ProvinceRepository    provinceRepository    = new ProvinceRepository(Connector);
            PublishModeRepository publishModeRepository = new PublishModeRepository(Connector);
            RegionRepository      regionRepository      = new RegionRepository(Connector);

            return(Connector.ExecuteReader(selectByPartnerQuery, new Dictionary <string, object>()
            {
                { "Partner", partner }
            }, reader =>
                                           ReadFromDataReader(reader, countryRepository, districtRepository, featureDetailRepository, pictureRepository, propertyTypeRepository, provinceRepository, publishModeRepository, regionRepository)));
        }
Ejemplo n.º 2
0
        private PropertyDTO ReadFromDataReader(IDataReader reader, CountryRepository countryRepository, DistrictRepository districtRepository, PropertyFeatureDetailRepository featureDetailRepository,
                                               PropertyPictureRepository pictureRepository, PropertyTypeRepository propertyTypeRepository, ProvinceRepository provinceRepository, PublishModeRepository publishModeRepository,
                                               RegionRepository regionRepository)
        {
            string     countryId = reader["Country"] as string, districtCode = reader["District"] as string, provinceCode = reader["Province"] as string, regionCode = reader["Region"] as string;
            Guid       propertyId    = (Guid)reader["Id"];
            byte?      publishModeId = reader["PublishMode"] as byte?;
            byte       typeId        = (byte)reader["Type"];
            CountryDTO country       = new CountryDTO()
            {
                Id          = countryId,
                DisplayName = new LocalizationDictionary(countryRepository.GetDisplayName(countryId)),
                Regions     = regionRepository.ReadByCountry(countryId)
            };
            PropertyDTO result = new PropertyDTO()
            {
                Id   = propertyId,
                Name = reader["Name"] as string,
                Type = new PropertyTypeDTO()
                {
                    Id          = typeId,
                    DisplayName = new LocalizationDictionary(propertyTypeRepository.GetDisplayName(typeId))
                },
                Address  = reader["Address"] as string,
                District = new DistrictDTO()
                {
                    Code        = districtCode,
                    Country     = country,
                    DisplayName = new LocalizationDictionary(districtRepository.GetDisplayName(countryId, districtCode))
                },
                Province = new ProvinceDTO()
                {
                    Code        = provinceCode,
                    Country     = country,
                    DisplayName = new LocalizationDictionary(provinceRepository.GetDisplayName(countryId, provinceCode)),
                    Districts   = districtRepository.ReadByCountryAndRegionAndProvince(countryId, regionCode, provinceCode)
                },
                Region = new RegionDTO()
                {
                    Code        = regionCode,
                    Country     = country,
                    DisplayName = new LocalizationDictionary(regionRepository.GetDisplayName(countryId, regionCode)),
                    Provinces   = provinceRepository.ReadByCountryAndRegion(countryId, regionCode)
                },
                Country = country,
                Partner = new PartnerDTO()
                {
                    Id = (Guid)reader["Partner"]
                },
                HasBeenPaid      = (bool)reader["HasBeenPaid"],
                HasBeenReviewed  = (bool)reader["HasBeenReviewed"],
                HasBeenPublished = (bool)reader["HasBeenPublished"],
                IsActive         = (bool)reader["IsActive"],
                Features         = featureDetailRepository.SelectByProperty(propertyId),
                Pictures         = pictureRepository.SelectByProperty(propertyId)
            };

            if (publishModeId != null)
            {
                result.PublishMode = new PublishModeDTO()
                {
                    Id          = publishModeId.Value,
                    DisplayName = new LocalizationDictionary(publishModeRepository.GetDisplayName(publishModeId.Value))
                };
            }
            return(result);
        }