protected static FR_L5CM_GCWRfT_0938_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5CM_GCWRfT_0938_Array(); //Put your code here ORM_CMN_Country.Query countryQuery = new ORM_CMN_Country.Query(); countryQuery.IsDeleted = false; countryQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Country> countries = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery); List <L5CM_GCWRfT_0938> countryList = new List <L5CM_GCWRfT_0938>(); foreach (var country in countries) { L5CM_GCWRfT_0938 item = new L5CM_GCWRfT_0938(); item.CMN_CountryID = country.CMN_CountryID; item.Country_ISOCode_Alpha2 = country.Country_ISOCode_Alpha2; item.Country_ISOCode_Alpha3 = country.Country_ISOCode_Alpha3; item.Country_ISOCode_Numeric = country.Country_ISOCode_Numeric; item.Country_Name = country.Country_Name; item.Default_Currency_RefID = country.Default_Currency_RefID; item.Default_Language_RefID = country.Default_Language_RefID; countryQuery = new ORM_CMN_Country.Query(); countryQuery.IsDeleted = false; countryQuery.Tenant_RefID = Guid.Empty; countryQuery.Country_ISOCode_Alpha2 = item.Country_ISOCode_Alpha2; countries = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery); ORM_CMN_LOC_Region.Query regionsQuery = new ORM_CMN_LOC_Region.Query(); regionsQuery.IsDeleted = false; regionsQuery.Country_RefID = countries[0].CMN_CountryID; List <ORM_CMN_LOC_Region> regions = ORM_CMN_LOC_Region.Query.Search(Connection, Transaction, regionsQuery); List <L5CM_GCWRfT_0938_Region> regionList = new List <L5CM_GCWRfT_0938_Region>(); foreach (var region in regions) { L5CM_GCWRfT_0938_Region regionItem = new L5CM_GCWRfT_0938_Region(); regionItem.CMN_LOC_RegionID = region.CMN_LOC_RegionID; regionItem.Parent_RefID = region.Parent_RefID; regionItem.Region_Name = region.Region_Name; regionItem.RegionExternalID = region.RegionExternalID; regionList.Add(regionItem); } item.Regions = regionList.ToArray(); countryList.Add(item); } returnValue.Result = countryList.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5TN_STCL_1439 Execute(DbConnection Connection, DbTransaction Transaction, P_L5TN_STCL_1439 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5TN_STCL_1439(); returnValue.Result = new L5TN_STCL_1439(); List <L5CM_GCWRfT_0938> countriesResult = new List <L5CM_GCWRfT_0938>(); //Put your code here ORM_CMN_Country.Query countryQuery = new ORM_CMN_Country.Query(); countryQuery.IsDeleted = false; countryQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Country> countryList = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery); ORM_CMN_Country country; L5CM_GCWRfT_0938 countryResultItem; foreach (var countryWithoutTenant in Parameter.CountriesWithoutTenant) { bool isCountryWithoutTenantInNewList = Parameter.NewListOfCountries.Any(i => i.Country_ISOCode_Alpha2 == countryWithoutTenant.Country_ISOCode_Alpha2); country = countryList.FirstOrDefault(i => i.Country_ISOCode_Alpha2 == countryWithoutTenant.Country_ISOCode_Alpha2); if (country == null) { if (isCountryWithoutTenantInNewList) { country = new ORM_CMN_Country(); country.Tenant_RefID = securityTicket.TenantID; country.Country_ISOCode_Alpha2 = countryWithoutTenant.Country_ISOCode_Alpha2; country.Country_ISOCode_Alpha3 = countryWithoutTenant.Country_ISOCode_Alpha3; country.Country_ISOCode_Numeric = countryWithoutTenant.Country_ISOCode_Numeric; Dict countryName = new Dict(countryWithoutTenant.Country_Name.SourceTable); countryName.DictionaryID = Guid.NewGuid(); List <DictEntry> entryItems = new List <DictEntry>(); entryItems.AddRange(countryWithoutTenant.Country_Name.Contents.Select(entry => new DictEntry() { Content = entry.Content, LanguageID = entry.LanguageID, DictID = countryName.DictionaryID, EntityID = Guid.NewGuid() })); countryName.Contents = entryItems; country.Country_Name = countryName; country.Default_Currency_RefID = countryWithoutTenant.Default_Currency_RefID; country.Default_Language_RefID = countryWithoutTenant.Default_Language_RefID; country.Save(Connection, Transaction); } } else { country.IsDeleted = !isCountryWithoutTenantInNewList; country.Save(Connection, Transaction); } if (country != null && !country.IsDeleted) { countryResultItem = new L5CM_GCWRfT_0938(); countryResultItem.CMN_CountryID = country.CMN_CountryID; countryResultItem.Country_ISOCode_Alpha2 = country.Country_ISOCode_Alpha2; countryResultItem.Country_ISOCode_Alpha3 = country.Country_ISOCode_Alpha3; countryResultItem.Country_ISOCode_Numeric = country.Country_ISOCode_Numeric; countryResultItem.Country_Name = country.Country_Name; countryResultItem.Default_Currency_RefID = country.Default_Currency_RefID; countryResultItem.Default_Language_RefID = country.Default_Language_RefID; countriesResult.Add(countryResultItem); } } returnValue.Result.Countries = countriesResult.ToArray(); return(returnValue); #endregion UserCode }