protected static FR_L5AAS_GCPfBPCC_0849_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5AAS_GCPfBPCC_0849 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5AAS_GCPfBPCC_0849_Array(); P_L5AAS_GCPIfBP_1607 ParamGetContactPerson = new P_L5AAS_GCPIfBP_1607(); ParamGetContactPerson.BusinessParticipantID = Parameter.BusinessParticipantID; var contactPersons = cls_Get_Contact_Person_Info_for_BusinessParticipantID.Invoke(Connection, Transaction, ParamGetContactPerson, securityTicket).Result; List <L5AAS_GCPfBPCC_0849> transformedContacts = new List <L5AAS_GCPfBPCC_0849>(); foreach (var cp in contactPersons) { L5AAS_GCPfBPCC_0849 transformedContact = new L5AAS_GCPfBPCC_0849(); transformedContact.CMN_BPT_BusinessParticipantID = cp.CMN_BPT_BusinessParticipantID; transformedContact.IsDeleted = cp.IsDeleted; transformedContact.AssociatedBusinessParticipant_RefID = cp.AssociatedBusinessParticipant_RefID; transformedContact.AssociatedParticipant_FunctionName = cp.AssociatedParticipant_FunctionName; transformedContact.CMN_PER_PersonInfoID = cp.CMN_PER_PersonInfoID; transformedContact.FirstName = cp.FirstName; transformedContact.LastName = cp.LastName; transformedContact.CMN_AddressID = cp.CMN_AddressID; transformedContact.Street_Name = cp.Street_Name; transformedContact.Street_Number = cp.Street_Number; transformedContact.City_Name = cp.City_Name; transformedContact.City_PostalCode = cp.City_PostalCode; transformedContact.Country_ISOCode = cp.Country_ISOCode; transformedContact.Email = GetContentByContentType(EnumUtils.GetEnumDescription(EComunactionContactType.Email), cp.ContactTypes); transformedContact.Phone = GetContentByContentType(EnumUtils.GetEnumDescription(EComunactionContactType.Phone), cp.ContactTypes); transformedContact.Fax = GetContentByContentType(EnumUtils.GetEnumDescription(EComunactionContactType.Fax), cp.ContactTypes); transformedContacts.Add(transformedContact); } returnValue.Result = transformedContacts.ToArray(); returnValue.Status = FR_Status.Success; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5AAS_SS_1355 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new CL1_CMN_BPT.ORM_CMN_BPT_Supplier(); var businessParticipant = new CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant(); var companyInfo = new CL1_CMN_COM.ORM_CMN_COM_CompanyInfo(); var universalContact = new CL1_CMN.ORM_CMN_UniversalContactDetail(); var discountValue = new CL1_CMN_BPT.ORM_CMN_BPT_Supplier_DiscountValue(); var cashDiscountValue = new CL1_CMN_BPT.ORM_CMN_BPT_Supplier_DiscountValue(); var discountQuery = new CL1_ORD_PRC.ORM_ORD_PRC_DiscountType.Query(); discountQuery.Tenant_RefID = securityTicket.TenantID; discountQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDiscountType.MainDiscount); var discount = CL1_ORD_PRC.ORM_ORD_PRC_DiscountType.Query.Search(Connection, Transaction, discountQuery).Single(); var scontoQuery = new CL1_ORD_PRC.ORM_ORD_PRC_DiscountType.Query(); scontoQuery.Tenant_RefID = securityTicket.TenantID; scontoQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDiscountType.CashDiscount); var sconto = CL1_ORD_PRC.ORM_ORD_PRC_DiscountType.Query.Search(Connection, Transaction, scontoQuery).SingleOrDefault(); if (Parameter.CMN_BPT_SupplierID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_BPT_SupplierID); if (item.Ext_BusinessParticipant_RefID != Guid.Empty) { businessParticipant.Load(Connection, Transaction, item.Ext_BusinessParticipant_RefID); } if (businessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID != Guid.Empty) { companyInfo.Load(Connection, Transaction, businessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID); } if (companyInfo.Contact_UCD_RefID != Guid.Empty) { universalContact.Load(Connection, Transaction, companyInfo.Contact_UCD_RefID); } var discountValueQuery = new CL1_CMN_BPT.ORM_CMN_BPT_Supplier_DiscountValue.Query(); discountValueQuery.Supplier_RefID = Parameter.CMN_BPT_SupplierID; discountValueQuery.Tenant_RefID = securityTicket.TenantID; discountValueQuery.ORD_PRC_DiscountType_RefID = discount.ORD_PRC_DiscountTypeID; var foundDiscountValue = CL1_CMN_BPT.ORM_CMN_BPT_Supplier_DiscountValue.Query.Search(Connection, Transaction, discountValueQuery); if (foundDiscountValue.Count == 1) { discountValue = foundDiscountValue.Single(); } var scontoValueQuery = new CL1_CMN_BPT.ORM_CMN_BPT_Supplier_DiscountValue.Query(); scontoValueQuery.Supplier_RefID = Parameter.CMN_BPT_SupplierID; scontoValueQuery.Tenant_RefID = securityTicket.TenantID; scontoValueQuery.ORD_PRC_DiscountType_RefID = sconto.ORD_PRC_DiscountTypeID; var foundCashValue = CL1_CMN_BPT.ORM_CMN_BPT_Supplier_DiscountValue.Query.Search(Connection, Transaction, scontoValueQuery); if (foundCashValue.Count == 1) { cashDiscountValue = foundCashValue.Single(); } } if (Parameter.IsDeleted == true) { item.IsDeleted = true; businessParticipant.IsDeleted = true; companyInfo.IsDeleted = true; universalContact.IsDeleted = true; #region Delete company info address P_L5AAS_GAfCI_1526 addressParam = new P_L5AAS_GAfCI_1526(); addressParam.CompanyInfoID = companyInfo.CMN_COM_CompanyInfoID; var addresses = cls_Get_Addresses_for_CompanyInfoID.Invoke(Connection, Transaction, addressParam, securityTicket).Result; foreach (var a in addresses) { P_L5AAS_SSA_1528 addressSaveParameter = new P_L5AAS_SSA_1528(); addressSaveParameter.CMN_COM_CompanyInfo_AddressID = a.CMN_COM_CompanyInfo_AddressID; addressSaveParameter.CompanyInfo_RefID = a.CompanyInfo_RefID; addressSaveParameter.IsDeleted = true; cls_Save_Supplier_Address.Invoke(Connection, Transaction, addressSaveParameter, securityTicket); } #endregion #region Delete Contact Persons P_L5AAS_GCPIfBP_1607 contactPersonParam = new P_L5AAS_GCPIfBP_1607(); contactPersonParam.BusinessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID; var contactPersons = cls_Get_Contact_Person_Info_for_BusinessParticipantID.Invoke(Connection, Transaction, contactPersonParam, securityTicket).Result; foreach (var c in contactPersons) { P_L5AAS_SSPCI_0832 contactPersonSaveParam = new P_L5AAS_SSPCI_0832(); contactPersonSaveParam.AssociatedBusinessParticipant_RefID = c.AssociatedBusinessParticipant_RefID; contactPersonSaveParam.CMN_AddressID = c.CMN_AddressID; contactPersonSaveParam.CMN_BPT_BusinessParticipantID = c.CMN_BPT_BusinessParticipantID; cls_Save_Supplier_Contact_Person_Info.Invoke(Connection, Transaction, contactPersonSaveParam, securityTicket); } #endregion businessParticipant.Save(Connection, Transaction); companyInfo.Save(Connection, Transaction); universalContact.Save(Connection, Transaction); return(new FR_Guid(item.Save(Connection, Transaction), item.CMN_BPT_SupplierID)); } //Creation specific parameters (Tenant, Account ... ) if (Parameter.CMN_BPT_SupplierID == Guid.Empty) { item.Tenant_RefID = securityTicket.TenantID; businessParticipant.Tenant_RefID = securityTicket.TenantID; companyInfo.Tenant_RefID = securityTicket.TenantID; universalContact.Tenant_RefID = securityTicket.TenantID; } item.SupplierType_RefID = Parameter.CMN_BPT_Supplier_TypeID; item.Ext_BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; item.ExternalSupplierProvidedIdentifier = Parameter.SupplierProvidedExternalIdentifier; businessParticipant.DisplayName = Parameter.DisplayName; businessParticipant.IsCompany = true; businessParticipant.DefaultCurrency_RefID = Parameter.DefaultCurrency_RefID; businessParticipant.DefaultLanguage_RefID = Parameter.DefaultLanguage_RefID; businessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; companyInfo.Contact_UCD_RefID = universalContact.CMN_UniversalContactDetailID; companyInfo.CompanyInfo_EstablishmentNumber = Parameter.CompanyInfo_EstablishmentNumber; companyInfo.AnnualRevenueAmountValue_RefID = Parameter.AnnualRevenueAmountValue_RefID; companyInfo.VATIdentificationNumber = Parameter.VATIdentificationNumber; universalContact.CompanyName_Line1 = Parameter.CompanyName_Line1; universalContact.Country_639_1_ISOCode = Parameter.Country_639_1_ISOCode; if (businessParticipant.CMN_BPT_BusinessParticipantID != Guid.Empty) { businessParticipant.Save(Connection, Transaction); } if (companyInfo.CMN_COM_CompanyInfoID != Guid.Empty) { companyInfo.Save(Connection, Transaction); } if (universalContact.CMN_UniversalContactDetailID != Guid.Empty) { universalContact.Save(Connection, Transaction); } Guid savedSupplier = new FR_Guid(item.Save(Connection, Transaction), item.CMN_BPT_SupplierID).Result; #region DiscountValue if (discountValue.Tenant_RefID == Guid.Empty) { discountValue.CMN_BPT_Supplier_DiscountValueID = Guid.NewGuid(); discountValue.Supplier_RefID = savedSupplier; discountValue.ORD_PRC_DiscountType_RefID = discount.ORD_PRC_DiscountTypeID; discountValue.Tenant_RefID = securityTicket.TenantID; } discountValue.DiscountValue_in_percent = Parameter.DiscountValue; discountValue.Save(Connection, Transaction); if (cashDiscountValue.Tenant_RefID == Guid.Empty) { cashDiscountValue.CMN_BPT_Supplier_DiscountValueID = Guid.NewGuid(); cashDiscountValue.Supplier_RefID = savedSupplier; cashDiscountValue.ORD_PRC_DiscountType_RefID = sconto.ORD_PRC_DiscountTypeID; cashDiscountValue.Tenant_RefID = securityTicket.TenantID; } cashDiscountValue.DiscountValue_in_percent = Parameter.CashDiscountValue; cashDiscountValue.Save(Connection, Transaction); #endregion returnValue.Result = savedSupplier; return(returnValue); #endregion UserCode }