Пример #1
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3SA_DSSAwCA_0201 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Base();

            ORM_LOG_REG_SupplierSelectionArea supplySelectionArea = ORM_LOG_REG_SupplierSelectionArea.Query.Search(Connection, Transaction, new ORM_LOG_REG_SupplierSelectionArea.Query()
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID,
                LOG_REG_SupplierSelectionAreaID = Parameter.SupplySelectionAreaID
            }).FirstOrDefault();

            if (supplySelectionArea == null)
            {
                returnValue.Status       = FR_Status.Error_Internal;
                returnValue.ErrorMessage = String.Format("SupplierSelectionArea entry with ID = {0} does not exist in database", Parameter.SupplySelectionAreaID);
                return(returnValue);
            }


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

            List <ORM_LOG_REG_SupplierSelectionArea_2_Country> supplySelectionArea2Countries = ORM_LOG_REG_SupplierSelectionArea_2_Country.Query.Search(Connection, Transaction, new ORM_LOG_REG_SupplierSelectionArea_2_Country.Query()
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID,
                LOG_REG_SupplierSelectionArea_RefID = Parameter.SupplySelectionAreaID
            });

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

            ORM_CMN_PRO_Product_SupplierAreaBinding.Query supplierAreaBindingQuery = new ORM_CMN_PRO_Product_SupplierAreaBinding.Query();
            supplierAreaBindingQuery.LOG_REG_SupplierSelectionArea_RefID = Parameter.SupplySelectionAreaID;
            supplierAreaBindingQuery.Tenant_RefID = securityTicket.TenantID;
            supplierAreaBindingQuery.IsDeleted    = false;
            List <ORM_CMN_PRO_Product_SupplierAreaBinding> supplierAreaBindingList = ORM_CMN_PRO_Product_SupplierAreaBinding.Query.Search(Connection, Transaction, supplierAreaBindingQuery);

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

            return(returnValue);

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

            //Put your code here
            ORM_CMN_PRO_Product_SupplierAreaBinding.Query supplierAreaBindingQuery = new ORM_CMN_PRO_Product_SupplierAreaBinding.Query();
            supplierAreaBindingQuery.CMN_PRO_Product_RefID = Parameter.ProductID;
            supplierAreaBindingQuery.Tenant_RefID          = securityTicket.TenantID;
            supplierAreaBindingQuery.IsDeleted             = false;
            List <ORM_CMN_PRO_Product_SupplierAreaBinding> supplierAreaBindingList = ORM_CMN_PRO_Product_SupplierAreaBinding.Query.Search(Connection, Transaction, supplierAreaBindingQuery);

            ORM_CMN_PRO_Product_SupplierAreaBinding supplierBinding;
            foreach (var binding in Parameter.SupplierSelectionAreasWithSuppliers)
            {
                if (supplierAreaBindingList.Any(i => i.LOG_REG_SupplierSelectionArea_RefID == binding.SupplierSelectionAreaID))
                {
                    // edit
                    supplierBinding = supplierAreaBindingList.First(i => i.LOG_REG_SupplierSelectionArea_RefID == binding.SupplierSelectionAreaID);

                    if (binding.SupplierID == Guid.Empty)
                    {
                        supplierBinding.Remove(Connection, Transaction);
                        continue;
                    }

                    supplierBinding.CMN_BPT_Supplier_RefID = binding.SupplierID;
                    supplierBinding.Save(Connection, Transaction);
                }
                else
                {
                    if (binding.SupplierID == Guid.Empty)
                    {
                        continue;
                    }

                    // create new
                    supplierBinding = new ORM_CMN_PRO_Product_SupplierAreaBinding();
                    supplierBinding.CMN_BPT_Supplier_RefID = binding.SupplierID;
                    supplierBinding.CMN_PRO_Product_RefID  = Parameter.ProductID;
                    supplierBinding.Tenant_RefID           = securityTicket.TenantID;
                    supplierBinding.LOG_REG_SupplierSelectionArea_RefID = binding.SupplierSelectionAreaID;
                    supplierBinding.IsDefault_ProductSupplier           = binding.SupplierSelectionAreaID == Guid.Empty;
                    supplierBinding.Save(Connection, Transaction);
                }
            }

            return(returnValue);

            #endregion UserCode
        }
Пример #3
0
        protected static FR_L5PS_GSSAwSfT_1720 Execute(DbConnection Connection, DbTransaction Transaction, P_L5PS_GSSAwSfT_1720 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5PS_GSSAwSfT_1720();

            //Put your code here
            L5PS_GSSAwSfT_1720         retVal = new L5PS_GSSAwSfT_1720();
            List <L5PS_GSSAwSfT_1720a> supplierSelectionAreaWithSuppliers = new List <L5PS_GSSAwSfT_1720a>();

            L2SP_GSfPaT_2351[] productSuppliers = new L2SP_GSfPaT_2351[0];

            #region Get Supplier Selection Areas

            var supplierSelectionAreasResult = cls_Get_SupplierSelectionAreas_for_Tenant.Invoke(Connection, Transaction, securityTicket);

            if (supplierSelectionAreasResult != null && supplierSelectionAreasResult.Result != null)
            {
                supplierSelectionAreaWithSuppliers.AddRange(supplierSelectionAreasResult.Result.Select(i => new L5PS_GSSAwSfT_1720a()
                {
                    SupplierID            = Guid.Empty,
                    SupplierSelectionArea = i
                }).ToList());
            }
            #endregion

            #region Get Product Suppliers
            P_L2SP_GSfPaT_2351 productSupplierParameter = new P_L2SP_GSfPaT_2351();
            productSupplierParameter.ProductID = Parameter.ProductID;
            var productSuppliersResult = cls_Get_Suppliers_for_Product_and_Tenant.Invoke(Connection, Transaction, productSupplierParameter, securityTicket);

            if (productSuppliersResult != null && productSuppliersResult.Result != null)
            {
                productSuppliers = productSuppliersResult.Result;
            }

            #endregion

            #region Get Supplier Area Bindings

            ORM_CMN_PRO_Product_SupplierAreaBinding.Query supplierAreaBindingQuery = new ORM_CMN_PRO_Product_SupplierAreaBinding.Query();
            supplierAreaBindingQuery.CMN_PRO_Product_RefID = Parameter.ProductID;
            supplierAreaBindingQuery.Tenant_RefID          = securityTicket.TenantID;
            supplierAreaBindingQuery.IsDeleted             = false;
            List <ORM_CMN_PRO_Product_SupplierAreaBinding> supplierAreaBindingList = ORM_CMN_PRO_Product_SupplierAreaBinding.Query.Search(Connection, Transaction, supplierAreaBindingQuery);

            foreach (var supplierArea in supplierAreaBindingList)
            {
                if (supplierArea.LOG_REG_SupplierSelectionArea_RefID == Guid.Empty)
                {
                    supplierSelectionAreaWithSuppliers.Add(new L5PS_GSSAwSfT_1720a()
                    {
                        SupplierID            = supplierArea.CMN_BPT_Supplier_RefID,
                        SupplierSelectionArea = new L3SA_GSSAfT_1734()
                        {
                            LOG_REG_SupplierSelectionAreaID = Guid.Empty
                        }
                    });
                }
                else if (supplierSelectionAreaWithSuppliers.Any(i => i.SupplierSelectionArea.LOG_REG_SupplierSelectionAreaID == supplierArea.LOG_REG_SupplierSelectionArea_RefID))
                {
                    supplierSelectionAreaWithSuppliers
                    .First(i => i.SupplierSelectionArea.LOG_REG_SupplierSelectionAreaID == supplierArea.LOG_REG_SupplierSelectionArea_RefID)
                    .SupplierID = supplierArea.CMN_BPT_Supplier_RefID;
                }
            }

            #endregion

            retVal.SupplierSelectionAreaWithSuppliers = supplierSelectionAreaWithSuppliers.ToArray();
            retVal.Suppliers = productSuppliers;

            returnValue.Result = retVal;

            return(returnValue);

            #endregion UserCode
        }