示例#1
0
        public IEnumerable <RegionDTO> ReadByCountry(string countryId)
        {
            ProvinceRepository provinceRepository = new ProvinceRepository(Connector);

            return(Connector.ExecuteReader(readByCountry, new Dictionary <string, object>()
            {
                { "Country", countryId },
            }, reader =>
            {
                string code = reader["Code"] as string, country = reader["Country"] as string;
                return new RegionDTO()
                {
                    Country = new CountryDTO()
                    {
                        Id = country
                    },
                    Code = code,
                    DisplayName = new LocalizationDictionary(GetDisplayName(countryId, code)),
                    Provinces = provinceRepository.ReadByCountryAndRegion(country, code)
                };
            }));
        }
示例#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);
        }
示例#3
0
        private PartnerDTO ReadFromDataReader(IDataReader reader, PartnerCardRepository cardRepository, CountryRepository countryRepository, CurrencyRepository currencyRepository,
                                              CustomerQuestionRepository customerQuestionRepository, DistrictRepository districtRepository, GenderRepository genderRepository, PartnerInvoiceRepository invoiceRepository,
                                              LanguageRepository languageRepository, PropertyRepository propertyRepository, ProvinceRepository provinceRepository, RegionRepository regionRepository)
        {
            string countryId = reader["Country"] as string, districtId = reader["District"] as string, genderId = reader["Gender"] as string,
                   preferredCurrencyId = reader["PreferredCurrencyId"] as string, preferredLanguageId = reader["PreferredLanguage"] as string, provinceId = reader["Province"] as string,
                   regionId    = reader["Region"] as string;
            CountryDTO country = new CountryDTO()
            {
                Id                  = countryId,
                DisplayName         = new LocalizationDictionary(countryRepository.GetDisplayName(countryId)),
                Regions             = regionRepository.ReadByCountry(countryId),
                SupportedCurrencies = countryRepository.GetSupportedCurrencies(countryId),
                SupportedLanguages  = countryRepository.GetSupportedLanguages(countryId)
            };
            Guid id = (Guid)reader["Id"];

            return(new PartnerDTO()
            {
                Id = id,
                Username = reader["Username"] as string,
                Password = reader["Password"] as byte[],
                FirstName = reader["FirstName"] as string,
                MiddleName = reader["MiddleName"] as string,
                LastName = reader["LastName"] as string,
                Gender = new GenderDTO()
                {
                    Id = genderId,
                    DisplayName = new LocalizationDictionary(genderRepository.GetDisplayName(genderId))
                },
                EmailAddress = reader["EmailAddress"] as string,
                MobileNumber = reader["MobileNumber"] as string,
                CompanyName = reader["CompanyName"] as string,
                Address = reader["Address"] as string,
                District = new DistrictDTO()
                {
                    Country = country,
                    Code = districtId,
                    DisplayName = new LocalizationDictionary(districtRepository.GetDisplayName(country.Id, districtId))
                },
                Province = new ProvinceDTO()
                {
                    Country = country,
                    Code = provinceId,
                    DisplayName = new LocalizationDictionary(provinceRepository.GetDisplayName(country.Id, provinceId)),
                    Districts = districtRepository.ReadByCountryAndRegionAndProvince(countryId, regionId, provinceId)
                },
                Region = new RegionDTO()
                {
                    Country = country,
                    Code = regionId,
                    DisplayName = new LocalizationDictionary(regionRepository.GetDisplayName(country.Id, regionId)),
                    Provinces = provinceRepository.ReadByCountryAndRegion(countryId, regionId)
                },
                Country = country,
                PhoneNumber = reader["PhoneNumber"] as string,
                Website = reader["Website"] as string,
                PreferredCurrency = new CurrencyDTO()
                {
                    Id = preferredCurrencyId,
                    DisplayName = new LocalizationDictionary(currencyRepository.GetDisplayName(preferredCurrencyId)),
                    Symbol = reader["PreferredCurrencySymbol"] as string
                },
                PreferredLanguage = new LanguageDTO()
                {
                    Id = preferredLanguageId,
                    DisplayName = new LocalizationDictionary(languageRepository.GetDisplayName(preferredLanguageId))
                },
                StripeId = reader["StripeId"] as string,
                HasEmailAddressBeenVerified = (bool)reader["HasEmailAddressBeenVerified"],
                IsLocked = (bool)reader["IsLocked"],
                IsActive = (bool)reader["IsActive"],
                Cards = cardRepository.SelectByPartner(id),
                CustomerQuestions = customerQuestionRepository.SelectByPartner(id),
                Invoices = invoiceRepository.SelectByPartner(id),
                Properties = propertyRepository.SelectByPartner(id)
            });
        }