示例#1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3ER_SERAC_1621 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here
            ORM_CMN_EconomicRegion economicRegion = new ORM_CMN_EconomicRegion();

            if (Parameter.CMN_EconomicRegionID != Guid.Empty)
            {
                var result = economicRegion.Load(Connection, Transaction, Parameter.CMN_EconomicRegionID);
                if (result.Status != FR_Status.Success || economicRegion.CMN_EconomicRegionID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }

            ORM_CMN_Country.Query countryQuery = new ORM_CMN_Country.Query();
            countryQuery.Country_ISOCode_Alpha2 = Parameter.Country_ISO;
            countryQuery.Tenant_RefID           = securityTicket.TenantID;
            countryQuery.IsDeleted = false;

            ORM_CMN_Country country = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery).FirstOrDefault();

            if (Parameter.CMN_EconomicRegionID != Guid.Empty)
            {
                ORM_CMN_Country_2_EconomicRegion.Query country2EconomicRegionQuery = new ORM_CMN_Country_2_EconomicRegion.Query();
                country2EconomicRegionQuery.CMN_EconomicRegion_RefID = Parameter.CMN_EconomicRegionID;
                country2EconomicRegionQuery.CMN_Country_RefID        = country.CMN_CountryID;
                country2EconomicRegionQuery.IsDeleted    = false;
                country2EconomicRegionQuery.Tenant_RefID = securityTicket.TenantID;
                if (ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction, country2EconomicRegionQuery).Count != 0)
                {
                    returnValue = new FR_Guid(Parameter.CMN_EconomicRegionID);
                    return(returnValue);
                }
            }
            foreach (var content in country.Country_Name.Contents)
            {
                economicRegion.EconomicRegion_Description.UpdateEntry(content.LanguageID, content.Content);
                economicRegion.EconomicRegion_Name.UpdateEntry(content.LanguageID, content.Content);
            }
            economicRegion.IsEconomicRegionCountry = true;
            economicRegion.Tenant_RefID            = securityTicket.TenantID;
            economicRegion.Save(Connection, Transaction);

            ORM_CMN_Country_2_EconomicRegion country2EconomicRegion = new ORM_CMN_Country_2_EconomicRegion();
            country2EconomicRegion.CMN_Country_RefID        = country.CMN_CountryID;
            country2EconomicRegion.CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID;
            country2EconomicRegion.Tenant_RefID             = securityTicket.TenantID;
            country2EconomicRegion.Save(Connection, Transaction);

            returnValue = new FR_Guid(economicRegion.CMN_EconomicRegionID);

            return(returnValue);

            #endregion UserCode
        }
示例#2
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3ER_DERwCA_1016 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Base();

            //Delete all children and after that economic region
            DeleteChildrenWithCountryAssignments(Connection, Transaction, Parameter.EconomicRegionID, securityTicket.TenantID);


            ORM_CMN_EconomicRegion economicRegion = ORM_CMN_EconomicRegion.Query.Search(Connection, Transaction, new ORM_CMN_EconomicRegion.Query()
            {
                IsDeleted            = false,
                Tenant_RefID         = securityTicket.TenantID,
                CMN_EconomicRegionID = Parameter.EconomicRegionID
            }).FirstOrDefault();

            if (economicRegion == null)
            {
                returnValue.Status       = FR_Status.Error_Internal;
                returnValue.ErrorMessage = String.Format("Economic region with id {0} does not exist.", Parameter.EconomicRegionID);
                return(returnValue);
            }

            economicRegion.IsDeleted = true;
            economicRegion.Save(Connection, Transaction);


            #region Delete all assignments

            List <ORM_CMN_Country_2_EconomicRegion> contry2EconomicRegions = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction, new ORM_CMN_Country_2_EconomicRegion.Query()
            {
                IsDeleted                = false,
                Tenant_RefID             = securityTicket.TenantID,
                CMN_EconomicRegion_RefID = Parameter.EconomicRegionID
            });

            foreach (var contry2EconomicRegion in contry2EconomicRegions)
            {
                contry2EconomicRegion.IsDeleted = true;
                contry2EconomicRegion.Save(Connection, Transaction);
            }

            #endregion

            return(returnValue);

            #endregion UserCode
        }
示例#3
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5TW_STW_1325 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            var item        = new ORM_CMN_STR_Profession();
            if (Parameter.CMN_STR_ProfessionID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_STR_ProfessionID);
                if (result.Status != FR_Status.Success || item.CMN_STR_ProfessionID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }
            item.GlobalPropertyMatchingID = Parameter.GlobalPropertyMatchingID;
            item.ProfessionName           = Parameter.ProfessionName;
            item.Tenant_RefID             = securityTicket.TenantID;
            item.Save(Connection, Transaction);

            ORM_CMN_STR_ProfessionKey.Query professionKeyQuery = new ORM_CMN_STR_ProfessionKey.Query();
            professionKeyQuery.CMN_STR_Profession_RefID = item.CMN_STR_ProfessionID;
            professionKeyQuery.IsDeleted    = false;
            professionKeyQuery.Tenant_RefID = securityTicket.TenantID;
            List <ORM_CMN_STR_ProfessionKey> professionKeys = ORM_CMN_STR_ProfessionKey.Query.Search(Connection, Transaction, professionKeyQuery);
            if (professionKeys.Count != 0)
            {
                ORM_CMN_STR_ProfessionKey professionKey = professionKeys[0];
                professionKey.SocialSecurityProfessionKey = Parameter.SocialSecurityProfessionKey;
                professionKey.Save(Connection, Transaction);
            }
            else
            {
                ORM_CMN_STR_ProfessionKey professionKey = new ORM_CMN_STR_ProfessionKey();
                professionKey.SocialSecurityProfessionKey = Parameter.SocialSecurityProfessionKey;
                professionKey.CMN_STR_Profession_RefID    = item.CMN_STR_ProfessionID;
                professionKey.Tenant_RefID = securityTicket.TenantID;


                ORM_CMN_Country.Query countryQuery = new ORM_CMN_Country.Query();
                countryQuery.Country_ISOCode_Alpha2 = Parameter.Country_ISOCode_Alpha2;
                countryQuery.IsDeleted    = false;
                countryQuery.Tenant_RefID = securityTicket.TenantID;

                List <ORM_CMN_Country> countries = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery);
                if (countries.Count != 0)
                {
                    ORM_CMN_Country country = countries[0];
                    ORM_CMN_Country_2_EconomicRegion.Query economicRegionToCountryQuery = new ORM_CMN_Country_2_EconomicRegion.Query();
                    economicRegionToCountryQuery.CMN_Country_RefID = country.CMN_CountryID;
                    economicRegionToCountryQuery.IsDeleted         = false;
                    economicRegionToCountryQuery.Tenant_RefID      = securityTicket.TenantID;
                    List <ORM_CMN_Country_2_EconomicRegion> economicRegionToCountries = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction, economicRegionToCountryQuery);
                    if (economicRegionToCountries.Count != 0)
                    {
                        ORM_CMN_EconomicRegion.Query economicRegionQuery = new ORM_CMN_EconomicRegion.Query();
                        economicRegionQuery.CMN_EconomicRegionID = economicRegionToCountries[0].CMN_EconomicRegion_RefID;
                        economicRegionQuery.IsDeleted            = false;
                        economicRegionQuery.Tenant_RefID         = securityTicket.TenantID;
                        List <ORM_CMN_EconomicRegion> economicRegions = ORM_CMN_EconomicRegion.Query.Search(Connection, Transaction, economicRegionQuery);
                        if (economicRegions.Count != 0)
                        {
                            professionKey.CMN_EconomicRegion_RefID = economicRegions[0].CMN_EconomicRegionID;
                        }
                    }
                    else
                    {
                        ORM_CMN_Country_2_EconomicRegion economicRegionToCountry = new ORM_CMN_Country_2_EconomicRegion();
                        economicRegionToCountry.CMN_Country_RefID = country.CMN_CountryID;
                        economicRegionToCountry.Tenant_RefID      = securityTicket.TenantID;

                        ORM_CMN_EconomicRegion economicRegion = new ORM_CMN_EconomicRegion();
                        economicRegion.IsEconomicRegionCountry           = true;
                        economicRegion.Tenant_RefID                      = securityTicket.TenantID;
                        economicRegionToCountry.CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID;

                        economicRegion.Save(Connection, Transaction);
                        economicRegionToCountry.Save(Connection, Transaction);
                        professionKey.CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID;
                    }
                }


                professionKey.Save(Connection, Transaction);
            }


            returnValue.Result = item.CMN_STR_ProfessionID;
            return(returnValue);

            #endregion UserCode
        }
示例#4
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3TX_STX_1119 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            // Set Economic region
            if (Parameter.EconomicRegion_RefID == Guid.Empty)
            {
                var countryRegion = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction,
                                                                                  new ORM_CMN_Country_2_EconomicRegion.Query {
                    IsDeleted = false, CMN_Country_RefID = Parameter.Country_RefID
                }).SingleOrDefault();

                if (countryRegion == null)
                {
                    var country = new ORM_CMN_Country();
                    country.Load(Connection, Transaction, Parameter.Country_RefID);
                    var region = new ORM_CMN_EconomicRegion();
                    region.EconomicRegion_Name = new Dict()
                    {
                        DictionaryID = Guid.NewGuid()
                    };
                    region.Tenant_RefID            = country.Tenant_RefID;
                    region.IsEconomicRegionCountry = true;
                    foreach (var content in country.Country_Name.Contents)
                    {
                        region.EconomicRegion_Name.AddEntry(content.LanguageID, content.Content);
                    }
                    region.Save(Connection, Transaction);
                    countryRegion = new ORM_CMN_Country_2_EconomicRegion();
                    countryRegion.CMN_EconomicRegion_RefID = region.CMN_EconomicRegionID;
                    countryRegion.CMN_Country_RefID        = country.CMN_CountryID;
                    countryRegion.Tenant_RefID             = country.Tenant_RefID;
                    countryRegion.Save(Connection, Transaction);
                }

                Parameter.EconomicRegion_RefID = countryRegion.CMN_EconomicRegion_RefID;
            }

            var item = new ORM_ACC_TAX_Tax();
            if (Parameter.ACC_TAX_TaxeID != Guid.Empty)
            {
                item.Load(Connection, Transaction, Parameter.ACC_TAX_TaxeID);
            }

            if (Parameter.IsDeleted == true)
            {
                item.IsDeleted = true;
                return(new FR_Guid(item.Save(Connection, Transaction), item.ACC_TAX_TaxeID));
            }

            //Creation specific parameters (Tenant, Account ... )
            if (Parameter.ACC_TAX_TaxeID == Guid.Empty)
            {
                item.Tenant_RefID = securityTicket.TenantID;
            }

            item.EconomicRegion_RefID = Parameter.EconomicRegion_RefID;
            item.TaxName = Parameter.TaxName;
            item.TaxRate = Parameter.TaxRate;

            return(new FR_Guid(item.Save(Connection, Transaction), item.ACC_TAX_TaxeID));

            #endregion UserCode
        }