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

            var price = new ORM_CMN_SLS_Price();

            //edit
            if (Parameter.CMN_SLS_PriceID != Guid.Empty)
            {
                var priceLoaded = price.Load(Connection, Transaction, Parameter.CMN_SLS_PriceID);
                if (priceLoaded.Status != FR_Status.Success)
                {
                    return(new FR_Guid("Not exist", FR_Status.Error_Internal));
                }
            }


            //fill price properties
            price.PricelistRelease_RefID = Parameter.PricelistRelease_RefID;
            price.CMN_PRO_Product_RefID  = Parameter.CMN_PRO_Product_RefID;
            price.PriceAmount            = Parameter.PriceAmount;

            returnValue = new FR_Guid(price.Save(Connection, Transaction), price.CMN_SLS_PriceID);

            return(returnValue);

            #endregion UserCode
        }
Beispiel #2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PL_SPfPRaPV_0920 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            foreach (var item in Parameter.Data)
            {
                foreach (var currentPrice in item.Prices)
                {
                    var price = new ORM_CMN_SLS_Price();
                    price.Tenant_RefID = securityTicket.TenantID;

                    if (currentPrice.PriceAmount == 0 && currentPrice.PriceID != Guid.Empty)
                    {
                        price.Load(Connection, Transaction, currentPrice.PriceID);

                        price.PriceAmount = 0;
                        price.IsDeleted   = true;

                        price.Save(Connection, Transaction);
                    }
                    else if (currentPrice.PriceAmount != 0)
                    {
                        if (currentPrice.PriceID != Guid.Empty)
                        {
                            price.Load(Connection, Transaction, currentPrice.PriceID);

                            price.PriceAmount = currentPrice.PriceAmount;

                            price.Save(Connection, Transaction);
                        }
                        else
                        {
                            var pricequery = new ORM_CMN_SLS_Price.Query();
                            pricequery.CMN_Currency_RefID            = currentPrice.CurrencyID;
                            pricequery.CMN_PRO_Product_Variant_RefID = item.ProductVariantID;
                            pricequery.PricelistRelease_RefID        = item.PricelistReleaseID;

                            var prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, pricequery);
                            if (prices != null && prices.Count > 0)
                            {
                                price             = prices.FirstOrDefault();
                                price.IsDeleted   = false;
                                price.PriceAmount = currentPrice.PriceAmount;

                                price.Save(Connection, Transaction);
                            }
                            else
                            {
                                var productVariant = new CL1_CMN_PRO.ORM_CMN_PRO_Product_Variant();
                                productVariant.Load(Connection, Transaction, item.ProductVariantID);

                                price.CMN_SLS_PriceID               = Guid.NewGuid();
                                price.CMN_Currency_RefID            = currentPrice.CurrencyID;
                                price.CMN_PRO_Product_Variant_RefID = item.ProductVariantID;
                                price.CMN_PRO_Product_RefID         = productVariant.CMN_PRO_Product_RefID;
                                price.PricelistRelease_RefID        = item.PricelistReleaseID;
                                price.PriceAmount = currentPrice.PriceAmount;

                                price.Save(Connection, Transaction);
                            }
                        }
                    }

                    returnValue.Result = price.CMN_SLS_PriceID;
                }
            }


            return(returnValue);

            #endregion UserCode
        }