protected static FR_L5CS_GCSSFCS_1320 Execute(DbConnection Connection, DbTransaction Transaction, P_L5CS_GCSSFCS_1320 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_L5CS_GCSSFCS_1320();

            ORM_CMN_PER_CompulsorySocialSecurityStatus.Query securityStatusQuery = new ORM_CMN_PER_CompulsorySocialSecurityStatus.Query();
            securityStatusQuery.CMN_PER_CompulsorySocialSecurityStatusID = Parameter.CMN_PER_CompulsorySocialSecurityStatusID;
            securityStatusQuery.IsDeleted    = false;
            securityStatusQuery.Tenant_RefID = securityTicket.TenantID;
            List <ORM_CMN_PER_CompulsorySocialSecurityStatus> securityStatuses = ORM_CMN_PER_CompulsorySocialSecurityStatus.Query.Search(Connection, Transaction, securityStatusQuery);
            if (securityStatuses != null && securityStatuses.Count != 0)
            {
                L5CS_GCSSFT_1319 securityStatusItem = new L5CS_GCSSFT_1319();

                ORM_CMN_PER_CompulsorySocialSecurityStatus securityStatus = securityStatuses[0];
                securityStatusItem.CMN_PER_CompulsorySocialSecurityStatusID = securityStatus.CMN_PER_CompulsorySocialSecurityStatusID;
                securityStatusItem.SocialSecurityStatus_Name        = securityStatus.SocialSecurityStatus_Name;
                securityStatusItem.GlobalPropertyMatchingID         = securityStatus.GlobalPropertyMatchingID;
                securityStatusItem.SocialSecurityStatus_Description = securityStatus.SocialSecurityStatus_Description;
                securityStatusItem.SocialSecurityStatus_Code        = securityStatus.SocialSecurityStatus_Code;
                securityStatusItem.Country_ISOCode_Alpha2           = Get_CountryISO_For_SocialSecurity(Connection, Transaction, securityTicket, securityStatus);
                returnValue.Result = new L5CS_GCSSFCS_1320();
                returnValue.Result.CompulsorySocialSecurityStatus = securityStatusItem;
            }
            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CS_SCSS_1318 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            var item        = new ORM_CMN_PER_CompulsorySocialSecurityStatus();
            if (Parameter.CMN_PER_CompulsorySocialSecurityStatusID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_PER_CompulsorySocialSecurityStatusID);
                if (result.Status != FR_Status.Success || item.CMN_PER_CompulsorySocialSecurityStatusID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }
            else
            {
                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();

                ORM_CMN_Country_2_EconomicRegion.Query country2EconomicRegionQuery = new ORM_CMN_Country_2_EconomicRegion.Query();
                country2EconomicRegionQuery.CMN_Country_RefID = country.CMN_CountryID;
                country2EconomicRegionQuery.IsDeleted         = false;
                country2EconomicRegionQuery.Tenant_RefID      = securityTicket.TenantID;

                List <ORM_CMN_Country_2_EconomicRegion> country2EconomicRegion = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction, country2EconomicRegionQuery);

                Guid economicRegionID;

                if (country2EconomicRegion.Count == 0)
                {
                    P_L3ER_SERAC_1621 param = new P_L3ER_SERAC_1621();
                    param.Country_ISO = Parameter.Country_ISO;
                    economicRegionID  = cls_Save_EconomicRegion_As_Country.Invoke(Connection, Transaction, param, securityTicket).Result;
                }
                else
                {
                    economicRegionID = country2EconomicRegion.FirstOrDefault().CMN_EconomicRegion_RefID;
                }

                item.CMN_EconomicRegion_RefID = economicRegionID;
            }
            item.SocialSecurityStatus_Name        = Parameter.SocialSecurityStatus_Name;
            item.SocialSecurityStatus_Description = Parameter.SocialSecurityStatus_Description;
            item.GlobalPropertyMatchingID         = Parameter.GlobalPropertyMatchingID;
            item.SocialSecurityStatus_Code        = Parameter.SocialSecurityStatus_Code;
            item.Tenant_RefID = securityTicket.TenantID;
            item.Save(Connection, Transaction);
            returnValue.Result = item.CMN_PER_CompulsorySocialSecurityStatusID;

            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L5CS_DCSS_1249 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Base();
            var item        = new ORM_CMN_PER_CompulsorySocialSecurityStatus();
            if (Parameter.CMN_PER_CompulsorySocialSecurityStatusID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_PER_CompulsorySocialSecurityStatusID);
                if (result.Status != FR_Status.Success || item.CMN_PER_CompulsorySocialSecurityStatusID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }
            item.IsDeleted = true;
            item.Save(Connection, Transaction);
            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
        private static string Get_CountryISO_For_SocialSecurity(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket, ORM_CMN_PER_CompulsorySocialSecurityStatus socialSecurity)
        {
            string ISO = "";

            ORM_CMN_EconomicRegion economicRegion;
            FR_Base economicRegionRes;
            ORM_CMN_Country_2_EconomicRegion countryEconomicRegion;
            ORM_CMN_Country country;
            FR_Base         countryRes;

            economicRegion    = new ORM_CMN_EconomicRegion();
            economicRegionRes = economicRegion.Load(Connection, Transaction, socialSecurity.CMN_EconomicRegion_RefID);

            if (economicRegionRes.Status != FR_Status.Success || economicRegion.CMN_EconomicRegionID == Guid.Empty)
            {
                return("");
            }

            countryEconomicRegion = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction,
                                                                                  new ORM_CMN_Country_2_EconomicRegion.Query()
            {
                Tenant_RefID             = securityTicket.TenantID,
                IsDeleted                = false,
                CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID
            }).FirstOrDefault();

            if (countryEconomicRegion == null)
            {
                return("");
            }

            country    = new ORM_CMN_Country();
            countryRes = country.Load(Connection, Transaction, countryEconomicRegion.CMN_Country_RefID);

            if (countryRes.Status != FR_Status.Success || country.CMN_CountryID == Guid.Empty)
            {
                return("");
            }

            ISO = country.Country_ISOCode_Alpha2;

            return(ISO);
        }