protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L5RL_DR_0941 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Base();
            var item        = new ORM_CMN_PER_Religion();
            if (Parameter.CMN_PER_ReligionID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_PER_ReligionID);
                if (result.Status != FR_Status.Success || item.CMN_PER_ReligionID == 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);

            ORM_CMN_PER_Religion_2_EconomicRegion.Query religion2EconomicRegionQuery = new ORM_CMN_PER_Religion_2_EconomicRegion.Query();
            religion2EconomicRegionQuery.CMN_PER_Religion_RefID = item.CMN_PER_ReligionID;
            religion2EconomicRegionQuery.IsDeleted    = false;
            religion2EconomicRegionQuery.Tenant_RefID = securityTicket.TenantID;

            var existingReligion2EconomicRegionArray = ORM_CMN_PER_Religion_2_EconomicRegion.Query.Search(Connection, Transaction, religion2EconomicRegionQuery);

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

            return(returnValue);

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

            var item = new ORM_CMN_PER_Religion();
            if (Parameter.CMN_PER_ReligionID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_PER_ReligionID);
                if (result.Status != FR_Status.Success || item.CMN_PER_ReligionID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }
            item.Religion_Name            = Parameter.Religion_Name;
            item.GlobalPropertyMatchingID = Parameter.GlobalPropertyMatchingID;
            item.Tenant_RefID             = securityTicket.TenantID;
            item.Save(Connection, Transaction);
            returnValue.Result = item.CMN_PER_ReligionID;

            if (Parameter.Country_ISO != "")
            {
                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;
                }

                if (Parameter.CMN_PER_ReligionID != Guid.Empty)
                {
                    ORM_CMN_PER_Religion_2_EconomicRegion.Query religion2EconomicRegionQuery = new ORM_CMN_PER_Religion_2_EconomicRegion.Query();
                    religion2EconomicRegionQuery.CMN_EconomicRegion_RefID = economicRegionID;
                    religion2EconomicRegionQuery.CMN_PER_Religion_RefID   = item.CMN_PER_ReligionID;
                    religion2EconomicRegionQuery.IsDeleted    = false;
                    religion2EconomicRegionQuery.Tenant_RefID = securityTicket.TenantID;

                    var existingReligion2EconomicRegion = ORM_CMN_PER_Religion_2_EconomicRegion.Query.Search(Connection, Transaction, religion2EconomicRegionQuery).FirstOrDefault();

                    if (existingReligion2EconomicRegion != null)
                    {
                        existingReligion2EconomicRegion.Religion_Code = Parameter.Religion_Code;
                        existingReligion2EconomicRegion.Save(Connection, Transaction);
                    }
                    else
                    {
                        ORM_CMN_PER_Religion_2_EconomicRegion religion2EconomicRegion = new ORM_CMN_PER_Religion_2_EconomicRegion();
                        religion2EconomicRegion.CMN_EconomicRegion_RefID = economicRegionID;
                        religion2EconomicRegion.CMN_PER_Religion_RefID   = item.CMN_PER_ReligionID;
                        religion2EconomicRegion.Religion_Code            = Parameter.Religion_Code;
                        religion2EconomicRegion.Tenant_RefID             = securityTicket.TenantID;
                        religion2EconomicRegion.Save(Connection, Transaction);
                    }
                }
                else
                {
                    ORM_CMN_PER_Religion_2_EconomicRegion religion2EconomicRegion = new ORM_CMN_PER_Religion_2_EconomicRegion();
                    religion2EconomicRegion.CMN_EconomicRegion_RefID = economicRegionID;
                    religion2EconomicRegion.CMN_PER_Religion_RefID   = item.CMN_PER_ReligionID;
                    religion2EconomicRegion.Religion_Code            = Parameter.Religion_Code;
                    religion2EconomicRegion.Tenant_RefID             = securityTicket.TenantID;
                    religion2EconomicRegion.Save(Connection, Transaction);
                }
            }
            else if (Parameter.CMN_PER_ReligionID != Guid.Empty)
            {
                ORM_CMN_PER_Religion_2_EconomicRegion.Query religion2EconomicRegionQuery = new ORM_CMN_PER_Religion_2_EconomicRegion.Query();
                religion2EconomicRegionQuery.CMN_PER_Religion_RefID = item.CMN_PER_ReligionID;
                religion2EconomicRegionQuery.IsDeleted    = false;
                religion2EconomicRegionQuery.Tenant_RefID = securityTicket.TenantID;

                var existingReligion2EconomicRegion = ORM_CMN_PER_Religion_2_EconomicRegion.Query.Search(Connection, Transaction, religion2EconomicRegionQuery).FirstOrDefault();

                if (existingReligion2EconomicRegion != null)
                {
                    existingReligion2EconomicRegion.Religion_Code = Parameter.Religion_Code;
                    existingReligion2EconomicRegion.Save(Connection, Transaction);
                }
            }



            //Put your code here
            return(returnValue);

            #endregion UserCode
        }