private DicCustomer ConvertToDicCustomer(Person person) { var customerTypePhysicalId = _context.DicCustomerTypes.First(c => c.Code == DicCustomerTypeCodes.Physical).Id; DicCountry countryKz = null; int? countryKzId = null; if (person.citizenship.code == "398") { countryKz = _context.DicCountries.First(c => c.Code == DicCountryCodes.Kazakhstan); countryKzId = countryKz.Id; } return(new DicCustomer { DateCreate = DateTimeOffset.Now, DateUpdate = DateTimeOffset.Now, Xin = person.iin, NameRu = $"{person.fio.surname ?? string.Empty} {person.fio.firstname ?? string.Empty} {person.fio.secondname ?? string.Empty}", Address = GetFullAddress(person.regAddress, LanguageType.Ru), AddressEn = GetFullAddress(person.regAddress, LanguageType.En), AddressKz = GetFullAddress(person.regAddress, LanguageType.Kz), City = string.IsNullOrEmpty(person.regAddress.city) ? person.regAddress.districts.nameRu : person.regAddress.city, Region = GetRegionName(person.regAddress, LanguageType.Ru), Oblast = GetDistrictName(person.regAddress, LanguageType.Ru), Republic = GetCountryName(person.regAddress, LanguageType.Ru), Street = person.regAddress.street, ShortAddress = GetFullAddress(person.regAddress, LanguageType.Ru), TypeId = customerTypePhysicalId, Apartment = person.regAddress.flat, Country = countryKz, CountryId = countryKzId }); }
private DicCustomer GetCustomer(JurInfo customerInfo) { var customerTypeJurId = _context.DicCustomerTypes.First(c => c.Code == DicCustomerTypeCodes.Juridical).Id; DicCountry countryKz = null; int? countryKzId = null; if (string.Equals(customerInfo.JurAddress.Country, "КАЗАХСТАН", StringComparison.OrdinalIgnoreCase)) { countryKz = _context.DicCountries.First(c => c.Code == DicCountryCodes.Kazakhstan); countryKzId = countryKz.Id; } return(new DicCustomer { TypeId = GetCustomerTypeId(customerInfo.OrgFormCode) ?? customerTypeJurId, Xin = customerInfo.BIN, DateCreate = DateTimeOffset.Now, Address = GetFullAddress(customerInfo.JurAddress, LanguageType.Ru), AddressEn = GetFullAddress(customerInfo.JurAddress, LanguageType.En), AddressKz = GetFullAddress(customerInfo.JurAddress, LanguageType.Kz), City = GetCityName(customerInfo.JurAddress, LanguageType.Ru), Region = GetRegionName(customerInfo.JurAddress, LanguageType.Ru), Oblast = GetDistrictName(customerInfo.JurAddress, LanguageType.Ru), Republic = GetCountryName(customerInfo.JurAddress, LanguageType.Ru), Street = GetStreetName(customerInfo.JurAddress, LanguageType.Ru), Apartment = customerInfo.JurAddress.Apartment, ShortAddress = GetFullAddress(customerInfo.JurAddress, LanguageType.Ru), CertificateNumber = customerInfo.CertNumber, CertificateSeries = customerInfo.CertSeries, NameRuLong = customerInfo.JurName?.NameRu, NameKzLong = customerInfo.JurName?.NameKz, NameEnLong = customerInfo.JurName?.NameEn, NameRu = customerInfo.JurName?.ShortNameRu ?? customerInfo.JurName?.NameRu, NameKz = customerInfo.JurName?.ShortNameKz ?? customerInfo.JurName?.NameKz, NameEn = customerInfo.JurName?.ShortNameEn ?? customerInfo.JurName?.NameEn, Rnn = customerInfo.RNN, RegDate = customerInfo.RegDate, ContactName = GetCompanyContactName(customerInfo, LanguageType.Ru), Country = countryKz, CountryId = countryKzId }); }