protected static FR_L5PR_CFfC_1332 Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_CFfC_1332 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5PR_CFfC_1332(); returnValue.Result = new L5PR_CFfC_1332(); var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.Pharmacy_TenantITL, Tenant_RefID = securityTicket.TenantID }; var pharmacyTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); //Customer doesn't exist if (pharmacyTenant == default(ORM_CMN_Tenant)) { pharmacyTenant = new ORM_CMN_Tenant(); pharmacyTenant.CMN_TenantID = Guid.NewGuid(); pharmacyTenant.TenantITL = Parameter.Pharmacy_TenantITL; pharmacyTenant.Tenant_RefID = securityTicket.TenantID; pharmacyTenant.Creation_Timestamp = DateTime.Now; pharmacyTenant.Save(Connection, Transaction); } var bp = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsTenant = true, IfTenant_Tenant_RefID = pharmacyTenant.CMN_TenantID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (bp == default(ORM_CMN_BPT_BusinessParticipant)) { bp = new ORM_CMN_BPT_BusinessParticipant(); bp.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bp.BusinessParticipantITL = ""; bp.DisplayName = Parameter.Pharmacy_CompanyName; bp.IsCompany = true; bp.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid(); bp.IsTenant = true; bp.IfTenant_Tenant_RefID = pharmacyTenant.CMN_TenantID; bp.Tenant_RefID = securityTicket.TenantID; bp.Creation_Timestamp = DateTime.Now; bp.Save(Connection, Transaction); } returnValue.Result.Pharmacy_TenantID = pharmacyTenant.CMN_TenantID; returnValue.Result.Pharmacy_BusinessParticipantID = bp.CMN_BPT_BusinessParticipantID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_CMN_CAL_CalendarInstance CalendarInstance = new ORM_CMN_CAL_CalendarInstance(); CalendarInstance.WeekStartsOnDay = 0; CalendarInstance.Tenant_RefID = securityTicket.TenantID; CalendarInstance.Save(Connection, Transaction); ORM_CMN_BPT_STA_SettingProfile profile = new ORM_CMN_BPT_STA_SettingProfile(); profile.IsLeaveTimeCalculated_InDays = true; L2LN_GAL_1526[] AllLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result; profile.StafMember_Caption = new Dict(); profile.StafMember_Caption.DictionaryID = Guid.NewGuid(); if (AllLanguages != null) { foreach (var lang in AllLanguages) { if (lang.ISO_639_1.ToUpper() == "DE") { profile.StafMember_Caption.AddEntry(lang.CMN_LanguageID, "Mitarbeiter"); } if (lang.ISO_639_1.ToUpper() == "EN") { profile.StafMember_Caption.AddEntry(lang.CMN_LanguageID, "Staff"); } } } profile.Tenant_RefID = securityTicket.TenantID; profile.Save(Connection, Transaction); ORM_CMN_Tenant tenant = new ORM_CMN_Tenant(); if (securityTicket.TenantID != Guid.Empty) { var result = tenant.Load(Connection, Transaction, securityTicket.TenantID); if (result.Status != FR_Status.Success || tenant.CMN_TenantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } tenant.CMN_BPT_STA_SettingProfile_RefID = profile.CMN_BPT_STA_SettingProfileID; tenant.CMN_CAL_CalendarInstance_RefID = CalendarInstance.CMN_CAL_CalendarInstanceID; tenant.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5TN_ST_1139 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_CMN_BPT_STA_SettingProfile profile = new ORM_CMN_BPT_STA_SettingProfile(); if (Parameter.CMN_BPT_STA_SettingProfileID != Guid.Empty) { var result = profile.Load(Connection, Transaction, Parameter.CMN_BPT_STA_SettingProfileID); if (result.Status != FR_Status.Success || profile.CMN_BPT_STA_SettingProfileID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } profile.IsLeaveTimeCalculated_InDays = Parameter.IsLeaveTimeCalculated_InDays; profile.IsLeaveTimeCalculated_InHours = Parameter.IsLeaveTimeCalculated_InHours; profile.StafMember_Caption = Parameter.StafMember_Caption; profile.Default_SurchargeCalculation_UseAccumulated = Parameter.Default_SurchargeCalculation_UseAccumulated; profile.Default_SurchargeCalculation_UseMaximum = Parameter.Default_SurchargeCalculation_UseMaximum; profile.Save(Connection, Transaction); ORM_CMN_Tenant item = new ORM_CMN_Tenant(); var result2 = item.Load(Connection, Transaction, securityTicket.TenantID); if (result2.Status != FR_Status.Success || item.CMN_TenantID == Guid.Empty) { item.CMN_TenantID = securityTicket.TenantID; } item.IsUsing_WorkAreas = Parameter.IsUsing_Offices; item.IsUsing_WorkAreas = Parameter.IsUsing_WorkAreas; item.IsUsing_Workplaces = Parameter.IsUsing_Workplaces; item.Save(Connection, Transaction); returnValue.Result = item.CMN_TenantID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3CA_CoUSfIC_1545 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); /* * @See if Supplier already exists in database * */ ORM_CMN_BPT_Supplier supplier = new ORM_CMN_BPT_Supplier(); var supplierQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); supplierQuery.BusinessParticipantITL = Parameter.SupplierITL; supplierQuery.Tenant_RefID = securityTicket.TenantID; supplierQuery.IsDeleted = false; var supplier_bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, supplierQuery).FirstOrDefault(); #region if supplier does not exist if (supplier_bussinessParticipant == null) { /* * @Make Supplier Data * */ var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.TenantITL, Tenant_RefID = securityTicket.TenantID }; var supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); } supplier.CMN_BPT_SupplierID = Guid.NewGuid(); supplier.Ext_BusinessParticipant_RefID = Guid.NewGuid();//supplierBussinessParticipant.CMN_BPT_BusinessParticipantID supplier.Creation_Timestamp = DateTime.Now; supplier.IsDeleted = false; supplier.Tenant_RefID = securityTicket.TenantID; supplier.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant supplierBussinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); supplierBussinessParticipant.CMN_BPT_BusinessParticipantID = supplier.Ext_BusinessParticipant_RefID; supplierBussinessParticipant.DisplayName = Parameter.Supplier_Name; supplierBussinessParticipant.BusinessParticipantITL = Parameter.SupplierITL; supplierBussinessParticipant.Creation_Timestamp = DateTime.Now; supplierBussinessParticipant.Tenant_RefID = securityTicket.TenantID; supplierBussinessParticipant.IsCompany = true; supplierBussinessParticipant.IsTenant = true; supplierBussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid();//companyInfo.CMN_COM_CompanyInfoID supplierBussinessParticipant.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfo.Creation_Timestamp = DateTime.Now; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.Contact_UCD_RefID = Guid.NewGuid();//universalContactDetail.CMN_UniversalContactDetailID companyInfo.Save(Connection, Transaction); ORM_CMN_UniversalContactDetail universalContactDetail = new ORM_CMN_UniversalContactDetail(); universalContactDetail.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetail.IsCompany = true; universalContactDetail.Country_639_1_ISOCode = Parameter.CountryISO; universalContactDetail.Street_Name = Parameter.Supplier_Name; universalContactDetail.Street_Number = Parameter.Street_Number; universalContactDetail.ZIP = Parameter.ZIP; universalContactDetail.Town = Parameter.Town; universalContactDetail.Region_Code = Parameter.Region_Code; universalContactDetail.Tenant_RefID = securityTicket.TenantID; universalContactDetail.Creation_Timestamp = DateTime.Now; universalContactDetail.Save(Connection, Transaction); } #endregion #region if supplier exists , check if its data is changed else { var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.TenantITL, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }; ORM_CMN_Tenant supplierTenant; if (ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).Count > 1) { supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).First(); //QUICKFIX } else { supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); } if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); supplier_bussinessParticipant.IsTenant = true; supplier_bussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; } supplier_bussinessParticipant.DisplayName = Parameter.Supplier_Name; supplier_bussinessParticipant.Save(Connection, Transaction); var query = new ORM_CMN_BPT_Supplier.Query(); query.Ext_BusinessParticipant_RefID = supplier_bussinessParticipant.CMN_BPT_BusinessParticipantID; query.Tenant_RefID = securityTicket.TenantID; query.IsDeleted = false; supplier = ORM_CMN_BPT_Supplier.Query.Search(Connection, Transaction, query).First(); //edit universal contact details var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = supplier_bussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfoQuery.Tenant_RefID = securityTicket.TenantID; companyInfoQuery.IsDeleted = false; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var universalContactDetailQuery = new ORM_CMN_UniversalContactDetail.Query(); universalContactDetailQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetailQuery.Tenant_RefID = securityTicket.TenantID; universalContactDetailQuery.IsDeleted = false; var universalContactDetail = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, universalContactDetailQuery).First(); universalContactDetail.Country_639_1_ISOCode = Parameter.CountryISO; universalContactDetail.Street_Name = Parameter.Supplier_Name; universalContactDetail.Street_Number = Parameter.Street_Number; universalContactDetail.ZIP = Parameter.ZIP; universalContactDetail.Town = Parameter.Town; universalContactDetail.Region_Code = Parameter.Region_Code; universalContactDetail.Save(Connection, Transaction); } #endregion returnValue.Result = supplier.CMN_BPT_SupplierID; return(returnValue); #endregion UserCode }
protected static FR_L3TE_CTITS_1108 Execute(DbConnection Connection, DbTransaction Transaction, P_L3TE_CTITS_1108 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3TE_CTITS_1108(); returnValue.Result = new L3TE_CTITS_1108(); returnValue.Status = FR_Status.Error_Internal; #region Load or Create Tenant var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.TenantITL, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }; var customerTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (customerTenant == default(ORM_CMN_Tenant)) { customerTenant = new ORM_CMN_Tenant(); customerTenant.CMN_TenantID = Guid.NewGuid(); customerTenant.TenantITL = Parameter.TenantITL; customerTenant.Tenant_RefID = securityTicket.TenantID; customerTenant.Creation_Timestamp = DateTime.Now; customerTenant.UniversalContactDetail_RefID = Guid.NewGuid(); if (customerTenant.Save(Connection, Transaction).Status != FR_Status.Success) { return(returnValue); } } #endregion #region Load or Create BusinessParticipant var businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsTenant = true, IfTenant_Tenant_RefID = customerTenant.CMN_TenantID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (businessParticipant == default(ORM_CMN_BPT_BusinessParticipant)) { businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); businessParticipant.BusinessParticipantITL = Parameter.BusinessParticipantITL; businessParticipant.DisplayName = Parameter.CompanyName; businessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid(); businessParticipant.IfTenant_Tenant_RefID = customerTenant.CMN_TenantID; businessParticipant.IsCompany = true; businessParticipant.IsTenant = true; businessParticipant.Tenant_RefID = securityTicket.TenantID; businessParticipant.Creation_Timestamp = DateTime.Now; if (businessParticipant.Save(Connection, Transaction).Status != FR_Status.Success) { return(returnValue); } } #endregion #region Load or Create CompanyInfo var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, new ORM_CMN_COM_CompanyInfo.Query() { CMN_COM_CompanyInfoID = businessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (companyInfo == default(ORM_CMN_COM_CompanyInfo)) { companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = businessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfo.Contact_UCD_RefID = Guid.NewGuid(); companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.Creation_Timestamp = DateTime.Now; if (companyInfo.Save(Connection, Transaction).Status != FR_Status.Success) { return(returnValue); } } #endregion #region Load or Create UniversalContactDetails for Tenant and CompanyInfo var ucdTenant = ORM_CMN_UniversalContactDetail.Query.Search( Connection, Transaction, new ORM_CMN_UniversalContactDetail.Query() { CMN_UniversalContactDetailID = customerTenant.UniversalContactDetail_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (ucdTenant == default(ORM_CMN_UniversalContactDetail)) { ucdTenant = new ORM_CMN_UniversalContactDetail(); ucdTenant.CMN_UniversalContactDetailID = customerTenant.UniversalContactDetail_RefID; ucdTenant.UniversalContactDetailsITL = Parameter.TenantUniversalContactDetailITL; ucdTenant.IsCompany = true; ucdTenant.CompanyName_Line1 = Parameter.CompanyName; ucdTenant.Contact_Email = Parameter.ContactEmail; ucdTenant.Tenant_RefID = securityTicket.TenantID; ucdTenant.Creation_Timestamp = DateTime.Now; if (ucdTenant.Save(Connection, Transaction).Status != FR_Status.Success) { return(returnValue); } } var ucdCompanyInfo = ORM_CMN_UniversalContactDetail.Query.Search( Connection, Transaction, new ORM_CMN_UniversalContactDetail.Query() { CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (ucdCompanyInfo == default(ORM_CMN_UniversalContactDetail)) { ucdCompanyInfo = new ORM_CMN_UniversalContactDetail(); ucdCompanyInfo.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; ucdCompanyInfo.UniversalContactDetailsITL = Parameter.CompanyInfoUniversalContactDetailITL; ucdCompanyInfo.IsCompany = true; ucdCompanyInfo.CompanyName_Line1 = Parameter.CompanyName; ucdCompanyInfo.Contact_Email = Parameter.ContactEmail; ucdCompanyInfo.Tenant_RefID = securityTicket.TenantID; ucdCompanyInfo.Creation_Timestamp = DateTime.Now; if (ucdCompanyInfo.Save(Connection, Transaction).Status != FR_Status.Success) { return(returnValue); } } #endregion returnValue.Result.TenantID = customerTenant.CMN_TenantID; returnValue.Result.BusinessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID; returnValue.Result.TenantUniversalContactDetailID = ucdTenant.CMN_UniversalContactDetailID; returnValue.Result.CompanyInfoUniversalContactDetailID = ucdCompanyInfo.CMN_UniversalContactDetailID; returnValue.Result.CompanyInfoID = companyInfo.CMN_COM_CompanyInfoID; returnValue.Status = FR_Status.Success; return(returnValue); #endregion UserCode }
protected static FR_L3CCfTaIC_1526_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3CCfTaIC_1526 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3CCfTaIC_1526_Array(); //Put your code here List <L3CCfTaIC_1526> ProductList = new List <L3CCfTaIC_1526>(); returnValue.Result = ProductList.ToArray(); var _service = CatalogServiceFactory.GetSubscriptionService(); //make data to send to Architecture so that they will know which catalog to update var subscriptionRequest = new SubscriptionRequest(); subscriptionRequest.CatalogCode = Parameter.CatalogCodeITL; Customer customer = new Customer(); // for only Tenant specific cases add Business Participant ID if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { customer.BusinessParticipantITL = Parameter.SubscribedBy_BusinessParticipant_RefID.ToString(); } else { customer.BusinessParticipantITL = securityTicket.TenantID.ToString(); } customer.TenantITL = securityTicket.TenantID.ToString(); customer.Name = Parameter.ClientName; // customer.SourceRealm = BOp.Infrastructure.PropertyRepository.Instance.RealmID.ToString(); subscriptionRequest.Customer = customer; /* * @see if catalog with the same ITL for that bussinessParticipant exists * */ var subscribedCatalogQuery = new ORM_CMN_PRO_SubscribedCatalog.Query(); subscribedCatalogQuery.Tenant_RefID = securityTicket.TenantID; subscribedCatalogQuery.CatalogCodeITL = Parameter.CatalogCodeITL; if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { subscribedCatalogQuery.SubscribedBy_BusinessParticipant_RefID = Parameter.SubscribedBy_BusinessParticipant_RefID; } subscribedCatalogQuery.IsDeleted = false; var subscribedCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, subscribedCatalogQuery).FirstOrDefault(); #region Get VAT var defaultCountryISOCode = cls_Get_DefaultCountryISOCode_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; var param = new P_L3TX_GTfCICaT_1359(); param.CountryISOCode = "DE"; var taxes = cls_Get_Taxes_for_CountryISOCode_and_TenantID.Invoke(Connection, Transaction, param, securityTicket).Result; //if there are no taxes for tenant Guid countryID = Guid.Empty; if (taxes.Length == 0) { var country = cls_Get_AllCountries_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result.FirstOrDefault(); if (country != null) { countryID = country.CMN_CountryID; } } else { countryID = taxes.First().CMN_CountryID; // ti slucajni posmatracu ovog koda nemoj zameriti na ovakvom resenju. } #endregion #region save if (subscribedCatalog == null) { /* * @save ORM_CMN_PRO_SubscribedCatalog * */ subscribedCatalog = new ORM_CMN_PRO_SubscribedCatalog(); subscribedCatalog.CMN_PRO_SubscribedCatalogID = Guid.NewGuid(); subscribedCatalog.CatalogCodeITL = Parameter.CatalogCodeITL; subscribedCatalog.SubscribedCatalog_Name = Parameter.CatalogName; subscribedCatalog.SubscribedBy_BusinessParticipant_RefID = Parameter.SubscribedBy_BusinessParticipant_RefID; subscribedCatalog.Tenant_RefID = securityTicket.TenantID; subscribedCatalog.SubscribedCatalog_ValidFrom = Parameter.ValidFrom_Date; subscribedCatalog.SubscribedCatalog_ValidThrough = Parameter.ValidTo_Date; subscribedCatalog.SubscribedCatalog_Description = Parameter.CatalogDescription; subscribedCatalog.Creation_Timestamp = DateTime.Now; subscribedCatalog.IsDeleted = false; subscribedCatalog.SubscribedCatalog_CurrentRevision = Parameter.CatalogVersion; subscribedCatalog.IsCatalogPublic = Parameter.IsCatalogPublic; // check if language with that ISO exists for Tenant (Lower, exmpl de) var languageQuery = new ORM_CMN_Language.Query(); languageQuery.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes.ToLower(); languageQuery.Tenant_RefID = securityTicket.TenantID; languageQuery.IsDeleted = false; var language = ORM_CMN_Language.Query.Search(Connection, Transaction, languageQuery).FirstOrDefault(); // if language does not exist for that Tenant if (language == null) { //check if language with that ISO exists for Tenant (Upper exmpl DE) languageQuery = new ORM_CMN_Language.Query(); languageQuery.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes.ToUpper(); languageQuery.Tenant_RefID = securityTicket.TenantID; languageQuery.IsDeleted = false; language = ORM_CMN_Language.Query.Search(Connection, Transaction, languageQuery).FirstOrDefault(); // if language does not exist for that Tenant if (language == null) { ORM_CMN_Language newLanguage = new ORM_CMN_Language(); newLanguage.CMN_LanguageID = Guid.NewGuid(); newLanguage.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes; newLanguage.Creation_Timestamp = DateTime.Now; newLanguage.Tenant_RefID = securityTicket.TenantID; newLanguage.IsDeleted = false; newLanguage.Save(Connection, Transaction); subscribedCatalog.SubscribedCatalog_Language_RefID = newLanguage.CMN_LanguageID; } else { subscribedCatalog.SubscribedCatalog_Language_RefID = language.CMN_LanguageID; } } else { subscribedCatalog.SubscribedCatalog_Language_RefID = language.CMN_LanguageID; } // check if currency with that ISO exists for Tenant var currencyQuery = new ORM_CMN_Currency.Query(); currencyQuery.ISO4127 = Parameter.CatalogCurrency_ISO_4217; currencyQuery.Tenant_RefID = securityTicket.TenantID; currencyQuery.IsDeleted = false; var currency = ORM_CMN_Currency.Query.Search(Connection, Transaction, currencyQuery).FirstOrDefault(); if (currency == null) { ORM_CMN_Currency newCurrency = new ORM_CMN_Currency(); newCurrency.CMN_CurrencyID = Guid.NewGuid(); newCurrency.ISO4127 = Parameter.CatalogCurrency_ISO_4217; newCurrency.Tenant_RefID = securityTicket.TenantID; newCurrency.Creation_Timestamp = DateTime.Now; newCurrency.Save(Connection, Transaction); subscribedCatalog.SubscribedCatalog_Currency_RefID = newCurrency.CMN_CurrencyID; } else { subscribedCatalog.SubscribedCatalog_Currency_RefID = currency.CMN_CurrencyID; } #region product group /* * @Search product group * */ ORM_CMN_PRO_ProductGroup productGroup = new ORM_CMN_PRO_ProductGroup(); var productGroupQuery = new ORM_CMN_PRO_ProductGroup.Query(); productGroupQuery.Tenant_RefID = securityTicket.TenantID; productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.Treatment); //if (Parameter.IsCatalogPublic == false) //{ // productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); //} //else //{ // productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.ABDA); //} // for only Tenant specific cases add Business Participant ID if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { productGroupQuery.GlobalPropertyMatchingID += Parameter.SubscribedBy_BusinessParticipant_RefID; } productGroupQuery.IsDeleted = false; productGroup = ORM_CMN_PRO_ProductGroup.Query.Search(Connection, Transaction, productGroupQuery).FirstOrDefault(); if (productGroup == null) { /* * @Create product group for products if product group for that BP and Tenent does not exist * */ productGroup = new ORM_CMN_PRO_ProductGroup(); productGroup.Tenant_RefID = securityTicket.TenantID; productGroup.Creation_Timestamp = DateTime.Now; productGroup.CMN_PRO_ProductGroupID = Guid.NewGuid(); productGroup.ProductGroup_Name = new Dict(ORM_CMN_PRO_ProductGroup.TableName); productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.Treatment); productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "Treatment Group"); //if (Parameter.IsCatalogPublic == false) //{ // productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); // productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "HauseList Group"); //} //else //{ // productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.ABDA); // productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "ABDA Group"); //} // for only Tenant specific cases add Business Participant ID if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { productGroup.GlobalPropertyMatchingID += Parameter.SubscribedBy_BusinessParticipant_RefID; productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "Treatment Group"); } productGroup.Save(Connection, Transaction); } #endregion #region create priceList for Catalog /* * @create pricelist_Release * */ ORM_CMN_SLS_Pricelist_Release pricelist_Release = new ORM_CMN_SLS_Pricelist_Release(); pricelist_Release.CMN_SLS_Pricelist_ReleaseID = Guid.NewGuid(); pricelist_Release.Release_Version = "v1"; if (Parameter.IsCatalogPublic == false) { pricelist_Release.PricelistRelease_ValidFrom = Parameter.ValidFrom_Date; pricelist_Release.PricelistRelease_ValidTo = Parameter.ValidTo_Date; } else { pricelist_Release.IsPricelistAlwaysActive = true; } pricelist_Release.Tenant_RefID = securityTicket.TenantID; pricelist_Release.Creation_Timestamp = DateTime.Now; pricelist_Release.Pricelist_RefID = Guid.NewGuid();//priceList.CMN_SLS_PricelistID pricelist_Release.Save(Connection, Transaction); /* * @create pricelist * */ ORM_CMN_SLS_Pricelist priceList = new ORM_CMN_SLS_Pricelist(); priceList.CMN_SLS_PricelistID = pricelist_Release.Pricelist_RefID; var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); Dict nameDict = new Dict("cmn_sls_pricelist"); if (Parameter.IsCatalogPublic == false) { for (int i = 0; i < DBLanguages.Count; i++) { nameDict.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.CatalogName + "_" + Parameter.ValidFrom_Date.ToShortDateString() + "_" + Parameter.ValidTo_Date.ToShortDateString()); } } else { for (int i = 0; i < DBLanguages.Count; i++) { nameDict.AddEntry(DBLanguages[i].CMN_LanguageID, "ABDA_PriceList"); } } priceList.Pricelist_Name = nameDict; priceList.Tenant_RefID = securityTicket.TenantID; priceList.Creation_Timestamp = DateTime.Now; priceList.Save(Connection, Transaction); #endregion if (Parameter.IsCatalogPublic == false) { #region create and save products in product group and give product its price , product amout and measure unit /* * @create and save products in product group * */ bool isAlreadyInABDA = false; foreach (var item in Parameter.Products) { ORM_CMN_PRO_Product product = new ORM_CMN_PRO_Product(); // only for Tenant specific cases add Business Participant ID (!Lucentis) if (Parameter.SubscribedBy_BusinessParticipant_RefID == Guid.Empty) { var productQuery = new ORM_CMN_PRO_Product.Query(); productQuery.ProductITL = item.ProductITL; productQuery.Tenant_RefID = securityTicket.TenantID; productQuery.IsDeleted = false; productQuery.IsProductAvailableForOrdering = true; product = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, productQuery).FirstOrDefault(); //if it is not in ABDA if (product == null) { product = new ORM_CMN_PRO_Product(); product.CMN_PRO_ProductID = Guid.NewGuid(); product.Creation_Timestamp = DateTime.Now; product.Tenant_RefID = securityTicket.TenantID; product.ProductITL = item.ProductITL; product.Product_Name = item.Product_Name; product.Product_Description = item.Product_Description; product.Product_Number = item.Product_Number; product.IsProduct_Article = item.IsProduct_Article; product.IsProductAvailableForOrdering = true; product.PackageInfo_RefID = Guid.NewGuid();//packageInfo.CMN_PRO_PAC_PackageInfoID isAlreadyInABDA = false; } else { isAlreadyInABDA = true; } } else { product.CMN_PRO_ProductID = Guid.NewGuid(); product.Creation_Timestamp = DateTime.Now; product.Tenant_RefID = securityTicket.TenantID; product.ProductITL = item.ProductITL; product.Product_Name = item.Product_Name; product.Product_Description = item.Product_Description; product.Product_Number = item.Product_Number; product.IsProduct_Article = item.IsProduct_Article; product.IsProductAvailableForOrdering = true; product.PackageInfo_RefID = Guid.NewGuid();//packageInfo.CMN_PRO_PAC_PackageInfoID isAlreadyInABDA = false; } product.IfImportedFromExternalCatalog_CatalogSubscription_RefID = subscribedCatalog.CMN_PRO_SubscribedCatalogID; product.Save(Connection, Transaction); L3CCfTaIC_1526 pro = new L3CCfTaIC_1526(); pro.ProductID = product.CMN_PRO_ProductID; if (product.IsProduct_Article) { pro.Dosage = item.Dosage; } pro.isEdit = false; ProductList.Add(pro); ORM_CMN_PRO_Product_2_ProductGroup product_2_productGroup = new ORM_CMN_PRO_Product_2_ProductGroup(); product_2_productGroup.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; product_2_productGroup.CMN_PRO_ProductGroup_RefID = productGroup.CMN_PRO_ProductGroupID; product_2_productGroup.Tenant_RefID = securityTicket.TenantID; product_2_productGroup.Creation_Timestamp = DateTime.Now; product_2_productGroup.Save(Connection, Transaction); if (isAlreadyInABDA == false) { ORM_CMN_SLS_Price price = new ORM_CMN_SLS_Price(); price.CMN_SLS_PriceID = Guid.NewGuid(); price.Tenant_RefID = securityTicket.TenantID; price.Creation_Timestamp = DateTime.Now; price.PricelistRelease_RefID = pricelist_Release.CMN_SLS_Pricelist_ReleaseID; price.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; price.PriceAmount = item.Price; price.CMN_Currency_RefID = subscribedCatalog.SubscribedCatalog_Currency_RefID; price.Save(Connection, Transaction); //add amount and Measure ORM_CMN_PRO_PAC_PackageInfo packageInfo = new ORM_CMN_PRO_PAC_PackageInfo(); packageInfo.CMN_PRO_PAC_PackageInfoID = product.PackageInfo_RefID; packageInfo.Tenant_RefID = securityTicket.TenantID; packageInfo.Creation_Timestamp = DateTime.Now; packageInfo.PackageContent_Amount = item.Amount; //check if MeasureUnit exists for this Tenant var unitsQuery = new ORM_CMN_Unit.Query(); unitsQuery.Tenant_RefID = securityTicket.TenantID; unitsQuery.ISOCode = item.MeasuredInUnit_ISO_um_ums; unitsQuery.IsDeleted = false; var measuredInUnit = ORM_CMN_Unit.Query.Search(Connection, Transaction, unitsQuery).FirstOrDefault(); if (measuredInUnit == null) { ORM_CMN_Unit newMeasuredInUnit = new ORM_CMN_Unit(); newMeasuredInUnit.Tenant_RefID = securityTicket.TenantID; newMeasuredInUnit.Creation_Timestamp = DateTime.Now; newMeasuredInUnit.ISOCode = item.MeasuredInUnit_ISO_um_ums; newMeasuredInUnit.CMN_UnitID = Guid.NewGuid(); newMeasuredInUnit.Save(Connection, Transaction); packageInfo.PackageContent_MeasuredInUnit_RefID = newMeasuredInUnit.CMN_UnitID; } else { packageInfo.PackageContent_MeasuredInUnit_RefID = measuredInUnit.CMN_UnitID; } packageInfo.Save(Connection, Transaction); if (countryID != Guid.Empty)// if there is a country for this Tenant { #region Create Taxes double productVAT = 0; Double.TryParse(item.VAT, out productVAT); var tax = taxes.Where(i => i.TaxRate == productVAT).SingleOrDefault(); if (tax == default(L3TX_GTfCICaT_1359)) { #region CreateTax var saveTaxParam = new P_L3TX_STX_1119(); saveTaxParam.ACC_TAX_TaxeID = Guid.Empty; saveTaxParam.TaxName = new Dict(ORM_ACC_TAX_Tax.TableName); saveTaxParam.TaxName.AddEntry(language.CMN_LanguageID, productVAT.ToString()); saveTaxParam.TaxRate = productVAT; if (taxes.Length != 0) { saveTaxParam.EconomicRegion_RefID = taxes.First().CMN_EconomicRegionID; saveTaxParam.Country_RefID = taxes.First().CMN_CountryID; } else { saveTaxParam.EconomicRegion_RefID = Guid.Empty; saveTaxParam.Country_RefID = countryID; } var saveTaxResult = cls_Save_Tax.Invoke(Connection, Transaction, saveTaxParam, securityTicket).Result; #endregion #region Update Available taxes param = new P_L3TX_GTfCICaT_1359(); param.CountryISOCode = "DE"; taxes = cls_Get_Taxes_for_CountryISOCode_and_TenantID.Invoke(Connection, Transaction, param, securityTicket).Result; tax = taxes.Where(i => i.TaxRate == productVAT).SingleOrDefault(); #endregion } var salesTax = new ORM_CMN_PRO_Product_SalesTaxAssignmnet(); salesTax.CMN_PRO_Product_SalesTaxAssignmnetID = Guid.NewGuid(); salesTax.Product_RefID = product.CMN_PRO_ProductID; salesTax.ApplicableSalesTax_RefID = tax.ACC_TAX_TaxeID; salesTax.Creation_Timestamp = DateTime.Now; salesTax.Tenant_RefID = securityTicket.TenantID; salesTax.Save(Connection, Transaction); #endregion } } } #endregion } /* * @See if Supplier already exists in database * */ ORM_CMN_BPT_Supplier supplier = new ORM_CMN_BPT_Supplier(); var supplierQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); supplierQuery.BusinessParticipantITL = Parameter.SupplierData.SupplierITL; supplierQuery.Tenant_RefID = securityTicket.TenantID; supplierQuery.IsDeleted = false; var supplier_bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, supplierQuery).FirstOrDefault(); #region if supplier does not exist if (supplier_bussinessParticipant == null) { /* * @Make Supplier Data * */ var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.SupplierData.TenantITL, Tenant_RefID = securityTicket.TenantID }; var supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.SupplierData.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); } supplier.CMN_BPT_SupplierID = Guid.NewGuid(); supplier.Ext_BusinessParticipant_RefID = Guid.NewGuid();//supplierBussinessParticipant.CMN_BPT_BusinessParticipantID supplier.Creation_Timestamp = DateTime.Now; supplier.IsDeleted = false; supplier.Tenant_RefID = securityTicket.TenantID; supplier.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant supplierBussinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); supplierBussinessParticipant.CMN_BPT_BusinessParticipantID = supplier.Ext_BusinessParticipant_RefID; supplierBussinessParticipant.DisplayName = Parameter.SupplierData.Supplier_Name; supplierBussinessParticipant.BusinessParticipantITL = Parameter.SupplierData.SupplierITL; supplierBussinessParticipant.Creation_Timestamp = DateTime.Now; supplierBussinessParticipant.Tenant_RefID = securityTicket.TenantID; supplierBussinessParticipant.IsCompany = true; supplierBussinessParticipant.IsTenant = true; supplierBussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid();//companyInfo.CMN_COM_CompanyInfoID supplierBussinessParticipant.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfo.Creation_Timestamp = DateTime.Now; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.Contact_UCD_RefID = Guid.NewGuid();//universalContactDetail.CMN_UniversalContactDetailID companyInfo.Save(Connection, Transaction); ORM_CMN_UniversalContactDetail universalContactDetail = new ORM_CMN_UniversalContactDetail(); universalContactDetail.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetail.IsCompany = true; universalContactDetail.Country_639_1_ISOCode = Parameter.SupplierData.CountryISO; universalContactDetail.Street_Name = Parameter.SupplierData.Supplier_Name; universalContactDetail.Street_Number = Parameter.SupplierData.Street_Number; universalContactDetail.ZIP = Parameter.SupplierData.ZIP; universalContactDetail.Town = Parameter.SupplierData.Town; universalContactDetail.Region_Code = Parameter.SupplierData.Region_Code; universalContactDetail.Tenant_RefID = securityTicket.TenantID; universalContactDetail.Creation_Timestamp = DateTime.Now; universalContactDetail.Save(Connection, Transaction); } #endregion #region if supplier exists , check if its data is changed else { var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.SupplierData.TenantITL, Tenant_RefID = securityTicket.TenantID }; var supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.SupplierData.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); supplier_bussinessParticipant.IsTenant = true; supplier_bussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; } supplier_bussinessParticipant.DisplayName = Parameter.SupplierData.Supplier_Name; supplier_bussinessParticipant.Save(Connection, Transaction); var query = new ORM_CMN_BPT_Supplier.Query(); query.Ext_BusinessParticipant_RefID = supplier_bussinessParticipant.CMN_BPT_BusinessParticipantID; query.Tenant_RefID = securityTicket.TenantID; query.IsDeleted = false; supplier = ORM_CMN_BPT_Supplier.Query.Search(Connection, Transaction, query).First(); //edit universal contact details var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = supplier_bussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfoQuery.Tenant_RefID = securityTicket.TenantID; companyInfoQuery.IsDeleted = false; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var universalContactDetailQuery = new ORM_CMN_UniversalContactDetail.Query(); universalContactDetailQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetailQuery.Tenant_RefID = securityTicket.TenantID; universalContactDetailQuery.IsDeleted = false; var universalContactDetail = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, universalContactDetailQuery).First(); universalContactDetail.Country_639_1_ISOCode = Parameter.SupplierData.CountryISO; universalContactDetail.Street_Name = Parameter.SupplierData.Supplier_Name; universalContactDetail.Street_Number = Parameter.SupplierData.Street_Number; universalContactDetail.ZIP = Parameter.SupplierData.ZIP; universalContactDetail.Town = Parameter.SupplierData.Town; universalContactDetail.Region_Code = Parameter.SupplierData.Region_Code; universalContactDetail.Save(Connection, Transaction); } #endregion subscribedCatalog.SubscribedCatalog_PricelistRelease_RefID = pricelist_Release.CMN_SLS_Pricelist_ReleaseID; subscribedCatalog.PublishingSupplier_RefID = supplier.CMN_BPT_SupplierID; subscribedCatalog.Save(Connection, Transaction); /* * @send Kika information which catalog has been subscribed to who * */ var result = _service.SubscribeToCatalog(subscriptionRequest); if (result.ResponseStatus != ResponseStatus.OK) { throw new Exception("Catalog subscription failed!"); } } #endregion returnValue.Result = ProductList.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2TR_CTR_1405 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_CMN_Tenant guestTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, new ORM_CMN_Tenant.Query() { IsDeleted = false, TenantITL = Parameter.GuestTenantID.ToString(), Tenant_RefID = Parameter.TenantID }).Single(); ORM_CMN_BPT_BusinessParticipant bp = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsTenant = true, IsDeleted = false, IfTenant_Tenant_RefID = guestTenant.CMN_TenantID, Tenant_RefID = Parameter.TenantID }).Single(); ORM_CMN_TRL_TrustRelationRequest request = ORM_CMN_TRL_TrustRelationRequest.Query.Search(Connection, Transaction, new ORM_CMN_TRL_TrustRelationRequest.Query() { IsDeleted = false, Tenant_RefID = Parameter.TenantID, TrustRelationRequestITL = Parameter.TrustRelationRequestITL, Requesting_BusinessParticipant_RefID = bp.CMN_BPT_BusinessParticipantID }).FirstOrDefault(); if (request == null) { if (Parameter.IsInvalidation) { throw new Exception("Trustreslation request doesnt exists!"); } request = new ORM_CMN_TRL_TrustRelationRequest() { CMN_TRL_TrustRelationRequestID = Guid.NewGuid(), Tenant_RefID = Parameter.TenantID, TrustRelationRequestITL = Parameter.TrustRelationRequestITL, Requesting_BusinessParticipant_RefID = bp.CMN_BPT_BusinessParticipantID, IsApproved = true }; } request.Title = Parameter.Title; request.Comment = Parameter.Comment; request.Save(Connection, Transaction); ORM_CMN_TRL_TrustRelation_Type type = ORM_CMN_TRL_TrustRelation_Type.Query.Search(Connection, Transaction, new ORM_CMN_TRL_TrustRelation_Type.Query() { IsDeleted = false, Tenant_RefID = Parameter.TenantID, TrustRelationTypeITL = Parameter.TrustRelationTypeITL }).FirstOrDefault(); if (type == null) { type = new ORM_CMN_TRL_TrustRelation_Type(); type.CMN_TRL_TrustRelation_TypeID = Guid.NewGuid(); type.Tenant_RefID = Parameter.TenantID; type.TrustRelationTypeITL = Parameter.TrustRelationTypeITL; type.Save(Connection, Transaction); } var activeTR = ORM_CMN_TRL_TrustRelation.Query.Search(Connection, Transaction, new ORM_CMN_TRL_TrustRelation.Query() { IsDeleted = false, Tenant_RefID = Parameter.TenantID, CMN_TRL_TrustRelation_Type_RefID = type.CMN_TRL_TrustRelation_TypeID, IsPaused = false, IsValid = true }).FirstOrDefault(); ORM_CMN_TRL_TrustRelation tr = ORM_CMN_TRL_TrustRelation.Query.Search(Connection, Transaction, new ORM_CMN_TRL_TrustRelation.Query() { IsDeleted = false, Tenant_RefID = Parameter.TenantID, CMN_TRL_TrustRelation_Type_RefID = type.CMN_TRL_TrustRelation_TypeID, CreatedFrom_TrustRelationRequest_RefID = request.CMN_TRL_TrustRelationRequestID, }).FirstOrDefault(); if (tr == null) { if (Parameter.IsInvalidation) { throw new Exception("Trustreslation request doesnt exists!"); } tr = new ORM_CMN_TRL_TrustRelation() { CMN_TRL_TrustRelationID = Guid.NewGuid(), Tenant_RefID = Parameter.TenantID, CMN_BPT_BusinessParticpant_RefID = bp.CMN_BPT_BusinessParticipantID, CMN_TRL_TrustRelation_Type_RefID = type.CMN_TRL_TrustRelation_TypeID, CreatedFrom_TrustRelationRequest_RefID = request.CMN_TRL_TrustRelationRequestID, IsValid = true }; ORM_CMN_TRL_TrustRelation_History history = new ORM_CMN_TRL_TrustRelation_History() { CMN_TRL_TrustRelation_HistoryID = Guid.NewGuid(), Tenant_RefID = Parameter.TenantID, TrustRelation_RefID = tr.CMN_TRL_TrustRelationID, }; history.Save(Connection, Transaction); tr.Save(Connection, Transaction); } else { if (Parameter.IsInvalidation) { tr.IsValid = false; tr.Save(Connection, Transaction); ORM_CMN_TRL_TrustRelation_History history = new ORM_CMN_TRL_TrustRelation_History() { CMN_TRL_TrustRelation_HistoryID = Guid.NewGuid(), Tenant_RefID = Parameter.TenantID, TrustRelation_RefID = tr.CMN_TRL_TrustRelationID, StatusType = 2 }; history.Save(Connection, Transaction); } return(returnValue); } if (activeTR != null && tr.CMN_TRL_TrustRelationID != activeTR.CMN_TRL_TrustRelationID) // invalidatin old active tr { activeTR.IsValid = false; activeTR.Save(Connection, Transaction); ORM_CMN_TRL_TrustRelation_History history = new ORM_CMN_TRL_TrustRelation_History() { CMN_TRL_TrustRelation_HistoryID = Guid.NewGuid(), Tenant_RefID = Parameter.TenantID, TrustRelation_RefID = activeTR.CMN_TRL_TrustRelationID, StatusType = 2 }; history.Save(Connection, Transaction); } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6TN_STS_1026 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_CMN_CAL_APR_ResponsiblePerson responsiblePersons = new ORM_CMN_CAL_APR_ResponsiblePerson(); if (Parameter.CMN_CAL_APR_ResponsiblePersonID != Guid.Empty) { var result = responsiblePersons.Load(Connection, Transaction, Parameter.CMN_CAL_APR_ResponsiblePersonID); if (result.Status != FR_Status.Success || responsiblePersons.CMN_CAL_APR_ResponsiblePersonID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } responsiblePersons.NumberOfResponsiblePersonsRequiredToApprove = Parameter.NumberOfResponsiblePersonsRequiredToApprove; responsiblePersons.Tenant_RefID = securityTicket.TenantID; responsiblePersons.Save(Connection, Transaction); ORM_CMN_CAL_Event_ApprovalProcess_Type eventApprovalProcessType = new ORM_CMN_CAL_Event_ApprovalProcess_Type(); if (Parameter.CMN_CAL_Event_ApprovalProcess_TypeID != Guid.Empty) { var result = eventApprovalProcessType.Load(Connection, Transaction, Parameter.CMN_CAL_Event_ApprovalProcess_TypeID); if (result.Status != FR_Status.Success || eventApprovalProcessType.CMN_CAL_Event_ApprovalProcess_TypeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } eventApprovalProcessType.Tenant_RefID = securityTicket.TenantID; eventApprovalProcessType.IsResponsiblePersonBased = true; eventApprovalProcessType.IfResponsiblePersonBased_RefID = responsiblePersons.CMN_CAL_APR_ResponsiblePersonID; eventApprovalProcessType.Save(Connection, Transaction); ORM_CMN_Tenant_ActiveApprovalProcessType activeApprovalProcessType = new ORM_CMN_Tenant_ActiveApprovalProcessType(); if (Parameter.CMN_Tenant_ActiveApprovalProcessTypeID != Guid.Empty) { var result = activeApprovalProcessType.Load(Connection, Transaction, Parameter.CMN_Tenant_ActiveApprovalProcessTypeID); if (result.Status != FR_Status.Success || activeApprovalProcessType.CMN_Tenant_ActiveApprovalProcessTypeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } activeApprovalProcessType.Tenant_RefID = securityTicket.TenantID; activeApprovalProcessType.IsActive = true; activeApprovalProcessType.CMN_CAL_Event_ApprovalProcess_Type_RefID = eventApprovalProcessType.CMN_CAL_Event_ApprovalProcess_TypeID; activeApprovalProcessType.Save(Connection, Transaction); ORM_CMN_Tenant tenantItem = new ORM_CMN_Tenant(); if (securityTicket.TenantID != Guid.Empty) { var result = tenantItem.Load(Connection, Transaction, securityTicket.TenantID); if (result.Status != FR_Status.Success || tenantItem.CMN_TenantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } tenantItem.IsUsing_Offices = Parameter.IsUsing_Offices; tenantItem.IsUsing_WorkAreas = Parameter.IsUsing_WorkAreas; tenantItem.IsUsing_Workplaces = Parameter.IsUsing_Workplaces; tenantItem.IsUsing_CostCenters = Parameter.IsUsing_CostCenters; tenantItem.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3EV_SSE_1048 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here if (Parameter.CalendarInstanceID == Guid.Empty) { ORM_CMN_Tenant tenant = new ORM_CMN_Tenant(); if (securityTicket.TenantID != Guid.Empty) { var result = tenant.Load(Connection, Transaction, securityTicket.TenantID); if (result.Status != FR_Status.Success || tenant.CMN_TenantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (tenant.CMN_CAL_CalendarInstance_RefID == Guid.Empty) { ORM_CMN_CAL_CalendarInstance instance = new ORM_CMN_CAL_CalendarInstance(); instance.WeekStartsOnDay = 1; instance.Save(Connection, Transaction); tenant.CMN_CAL_CalendarInstance_RefID = instance.CMN_CAL_CalendarInstanceID; tenant.Save(Connection, Transaction); } } ORM_CMN_CAL_Event calendarEvent = new ORM_CMN_CAL_Event(); if (Parameter.CMN_CAL_EventID != Guid.Empty) { var result = calendarEvent.Load(Connection, Transaction, Parameter.CMN_CAL_EventID); if (result.Status != FR_Status.Success || calendarEvent.CMN_CAL_EventID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } calendarEvent.CalendarInstance_RefID = Parameter.CalendarInstanceID; calendarEvent.EndTime = Parameter.EndTime; calendarEvent.IsRepetitive = Parameter.IsRepetitive; calendarEvent.R_EventDuration_sec = Parameter.R_EventDuration_sec; calendarEvent.StartTime = Parameter.StartTime; calendarEvent.Tenant_RefID = securityTicket.TenantID; calendarEvent.CalendarInstance_RefID = Parameter.CalendarInstanceID; if (Parameter.IsRepetitive) { ORM_CMN_CAL_Repetition repetition = new ORM_CMN_CAL_Repetition(); if (Parameter.CMN_CAL_RepetitionID != Guid.Empty) { var result = repetition.Load(Connection, Transaction, Parameter.CMN_CAL_RepetitionID); if (result.Status != FR_Status.Success || repetition.CMN_CAL_RepetitionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } repetition.IsDaily = Parameter.IsDaily; repetition.IsMonthly = Parameter.IsMonthly; repetition.IsWeekly = Parameter.IsWeekly; repetition.IsYearly = Parameter.IsYearly; repetition.R_CronExpression = Parameter.R_CronExpression; repetition.Tenant_RefID = securityTicket.TenantID; repetition.Save(Connection, Transaction); calendarEvent.IsRepetitive = true; calendarEvent.Repetition_RefID = repetition.CMN_CAL_RepetitionID; ORM_CMN_CAL_Repetition_Ranx repetitionRange = new ORM_CMN_CAL_Repetition_Ranx(); if (Parameter.repetitionRangesCMN_CAL_Repetition_RangeID != Guid.Empty) { var result = repetitionRange.Load(Connection, Transaction, Parameter.repetitionRangesCMN_CAL_Repetition_RangeID); if (result.Status != FR_Status.Success || repetitionRange.CMN_CAL_Repetition_RangeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } repetitionRange.End_AfterSpecifiedOccurrences = Parameter.repetitionRangesEnd_AfterSpecifiedOccurrences; repetitionRange.End_ByDate = Parameter.repetitionRangesEnd_ByDate; repetitionRange.HasEndType_DateTime = Parameter.repetitionRangesHasEndType_DateTime; repetitionRange.HasEndType_NoEndDate = Parameter.repetitionRangesHasEndType_NoEndDate; repetitionRange.HasEndType_Occurrence = Parameter.repetitionRangesHasEndType_Occurrence; repetitionRange.Repetition_RefID = repetition.CMN_CAL_RepetitionID; repetitionRange.Tenant_RefID = securityTicket.TenantID; repetitionRange.Save(Connection, Transaction); if (Parameter.IsDaily) { ORM_CMN_CAL_RepetitionPatterns_Daily daily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); if (Parameter.dailyCMN_CAL_RepetitionPattern_DailyID != Guid.Empty) { var result = daily.Load(Connection, Transaction, Parameter.dailyCMN_CAL_RepetitionPattern_DailyID); if (result.Status != FR_Status.Success || daily.CMN_CAL_RepetitionPattern_DailyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } daily.Repetition_EveryNumberOfDays = Parameter.dailyRepetition_EveryNumberOfDays; daily.Repetition_RefID = repetition.CMN_CAL_RepetitionID; daily.Tenant_RefID = securityTicket.TenantID; daily.Save(Connection, Transaction); } else if (Parameter.IsWeekly) { ORM_CMN_CAL_RepetitionPatterns_Weekly weekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); if (Parameter.weeklyCMN_CAL_RepetitionPattern_WeeklyID != Guid.Empty) { var result = weekly.Load(Connection, Transaction, Parameter.weeklyCMN_CAL_RepetitionPattern_WeeklyID); if (result.Status != FR_Status.Success || weekly.CMN_CAL_RepetitionPattern_WeeklyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } weekly.HasRepeatingOn_Fridays = Parameter.weeklyHasRepeatingOn_Fridays; weekly.HasRepeatingOn_Mondays = Parameter.weeklyHasRepeatingOn_Mondays; weekly.HasRepeatingOn_Saturdays = Parameter.weeklyHasRepeatingOn_Saturdays; weekly.HasRepeatingOn_Sundays = Parameter.weeklyHasRepeatingOn_Sundays; weekly.HasRepeatingOn_Thursdays = Parameter.weeklyHasRepeatingOn_Thursdays; weekly.HasRepeatingOn_Tuesdays = Parameter.weeklyHasRepeatingOn_Tuesdays; weekly.HasRepeatingOn_Wednesdays = Parameter.weeklyHasRepeatingOn_Wednesdays; weekly.Repetition_EveryNumberOfWeeks = Parameter.weeklyRepetition_EveryNumberOfWeeks; weekly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; weekly.Tenant_RefID = securityTicket.TenantID; weekly.Save(Connection, Transaction); } else if (Parameter.IsMonthly) { ORM_CMN_CAL_RepetitionPatterns_Monthly monthly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); if (Parameter.monthlyCMN_CAL_RepetitionPattern_MonthlyID != Guid.Empty) { var result = monthly.Load(Connection, Transaction, Parameter.monthlyCMN_CAL_RepetitionPattern_MonthlyID); if (result.Status != FR_Status.Success || monthly.CMN_CAL_RepetitionPattern_MonthlyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } monthly.Repetition_EveryNumberOfMonths = Parameter.monthlyRepetition_EveryNumberOfMonths; monthly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; monthly.Tenant_RefID = securityTicket.TenantID; if (Parameter.monthlyIsRelative) { monthly.IsFixed = false; monthly.IsRelative = true; ORM_CMN_CAL_RepetitionPatterns_Relative relative = new ORM_CMN_CAL_RepetitionPatterns_Relative(); if (Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID != Guid.Empty) { var result = relative.Load(Connection, Transaction, Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID); if (result.Status != FR_Status.Success || relative.CMN_CAL_RepetitionPattern_RelativeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } relative.IsFriday = Parameter.relativeIsFriday; relative.IsMonday = Parameter.relativeIsMonday; relative.IsSaturday = Parameter.relativeIsSaturday; relative.IsSunday = Parameter.relativeIsSunday; relative.IsThursday = Parameter.relativeIsThursday; relative.IsTuesday = Parameter.relativeIsTuesday; relative.IsWednesday = Parameter.relativeIsWednesday; relative.IsWeekDay = Parameter.relativeIsWeekDay; relative.IsWeekendDay = Parameter.relativeIsWeekendDay; relative.Ordinal = Parameter.relativeOrdinal; relative.Tenant_RefID = securityTicket.TenantID; relative.Save(Connection, Transaction); monthly.IfRelative_RepetitionPattern_RefID = relative.CMN_CAL_RepetitionPattern_RelativeID; } else { monthly.IsRelative = false; monthly.IsFixed = true; monthly.IfFixed_DayOfMonth = Parameter.monthlyIfFixed_DayOfMonth; } monthly.Save(Connection, Transaction); } else { ORM_CMN_CAL_RepetitionPatterns_Yearly yearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); if (Parameter.yearlyCMN_CAL_RepetitionPattern_YearlyID != Guid.Empty) { var result = yearly.Load(Connection, Transaction, Parameter.yearlyCMN_CAL_RepetitionPattern_YearlyID); if (result.Status != FR_Status.Success || yearly.CMN_CAL_RepetitionPattern_YearlyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } yearly.Repetition_EveryNumberOfYears = Parameter.yearlyRepetition_EveryNumberOfYears; yearly.Repetition_Month = Parameter.yearlyRepetition_Month; yearly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; yearly.Tenant_RefID = securityTicket.TenantID; if (Parameter.yearlyIsRelative) { yearly.IsRelative = true; yearly.IsFixed = false; ORM_CMN_CAL_RepetitionPatterns_Relative relative = new ORM_CMN_CAL_RepetitionPatterns_Relative(); if (Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID != Guid.Empty) { var result = relative.Load(Connection, Transaction, Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID); if (result.Status != FR_Status.Success || relative.CMN_CAL_RepetitionPattern_RelativeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } relative.IsFriday = Parameter.relativeIsFriday; relative.IsMonday = Parameter.relativeIsMonday; relative.IsSaturday = Parameter.relativeIsSaturday; relative.IsSunday = Parameter.relativeIsSunday; relative.IsThursday = Parameter.relativeIsThursday; relative.IsTuesday = Parameter.relativeIsTuesday; relative.IsWednesday = Parameter.relativeIsWednesday; relative.IsWeekDay = Parameter.relativeIsWeekDay; relative.IsWeekendDay = Parameter.relativeIsWeekendDay; relative.Ordinal = Parameter.relativeOrdinal; relative.Tenant_RefID = securityTicket.TenantID; relative.Save(Connection, Transaction); yearly.IfRelative_RepetitionPattern_RefID = relative.CMN_CAL_RepetitionPattern_RelativeID; yearly.IsFixed = false; } else { yearly.IsRelative = false; yearly.IsFixed = true; yearly.IfFixed_DayOfMonth = Parameter.yearlyIfFixed_DayOfMonth; } yearly.Save(Connection, Transaction); } } else { calendarEvent.IsRepetitive = false; calendarEvent.Repetition_RefID = Guid.Empty; } calendarEvent.Save(Connection, Transaction); ORM_CMN_STR_SCE_StructureCalendarEvent structureEvent = new ORM_CMN_STR_SCE_StructureCalendarEvent(); if (Parameter.CMN_STR_SCE_StructureCalendarEventID != Guid.Empty) { var result = structureEvent.Load(Connection, Transaction, Parameter.CMN_STR_SCE_StructureCalendarEventID); if (result.Status != FR_Status.Success || structureEvent.CMN_STR_SCE_StructureCalendarEventID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (Parameter.IsHavingCapacityRestriction) { ORM_CMN_STR_SCE_CapacityRestriction capacityRestriction = new ORM_CMN_STR_SCE_CapacityRestriction(); if (Parameter.CMN_STR_SCE_CapacityRestrictionID != Guid.Empty) { var result = capacityRestriction.Load(Connection, Transaction, Parameter.CMN_STR_SCE_CapacityRestrictionID); if (result.Status != FR_Status.Success || capacityRestriction.CMN_STR_SCE_CapacityRestrictionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } capacityRestriction.IsValueCalculated_InHeadCount = Parameter.IsValueCalculated_InHeadCount; capacityRestriction.IsValueCalculated_InPercentage = Parameter.IsValueCalculated_InPercentage; capacityRestriction.IsValueCalculated_InWorkingHours = Parameter.IsValueCalculated_InWorkingHours; capacityRestriction.CapacityRestrictionType_RefID = Parameter.CMN_STR_SCE_CapacityRestriction_TypeID; capacityRestriction.Tenant_RefID = securityTicket.TenantID; capacityRestriction.ValueCalculated = Parameter.ValueCalculated; capacityRestriction.Save(Connection, Transaction); structureEvent.IfHavingCapacityRestriction_Restriction_RefID = capacityRestriction.CMN_STR_SCE_CapacityRestrictionID; structureEvent.IsHavingCapacityRestriction = true; } else { structureEvent.IsHavingCapacityRestriction = false; } var eventType = new ORM_CMN_STR_SCE_StructureCalendarEvent_Type(); var resultForType = eventType.Load(Connection, Transaction, Parameter.StructureCalendarEvent_Type_RefID); if (resultForType.Status != FR_Status.Success || eventType.CMN_STR_SCE_StructureCalendarEvent_TypeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } structureEvent.IsWorkingDayEvent = eventType.IsWorkingDay; structureEvent.IsWorkingHalfDayEvent = eventType.IsHalfWorkingDay; structureEvent.IsNonWorkingDay = eventType.IsNonWorkingDay; structureEvent.CMN_CAL_Event_RefID = calendarEvent.CMN_CAL_EventID; structureEvent.StructureCalendarEvent_Type_RefID = Parameter.StructureCalendarEvent_Type_RefID; structureEvent.R_CalendarInstance_RefID = Parameter.CalendarInstanceID; structureEvent.StructureEvent_Description = Parameter.StructureEvent_Description; structureEvent.StructureEvent_Name = Parameter.StructureEvent_Name; structureEvent.Tenant_RefID = securityTicket.TenantID; structureEvent.IsEvent_ImportedFromTemplate = Parameter.IsEvent_ImportedFromTemplate; structureEvent.IsBusinessDay = Parameter.IsBusinessDay; structureEvent.Save(Connection, Transaction); returnValue.Result = structureEvent.CMN_STR_SCE_StructureCalendarEventID; ORM_CMN_STR_SCE_ForbiddenLeaveType whereInstanceForbiddenLeaveType = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_SCE_ForbiddenLeaveType>(); whereInstanceForbiddenLeaveType.CMN_STR_SCE_StructureCalendarEvent_RefID = structureEvent.CMN_STR_SCE_StructureCalendarEventID; CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceForbiddenLeaveType); foreach (var forbidenLeaveType in Parameter.forbidenLeaveTypes) { ORM_CMN_STR_SCE_ForbiddenLeaveType item = new ORM_CMN_STR_SCE_ForbiddenLeaveType(); if (forbidenLeaveType.CMN_STR_SCE_ForbiddenLeaveTypeID != Guid.Empty) { var result = item.Load(Connection, Transaction, forbidenLeaveType.CMN_STR_SCE_ForbiddenLeaveTypeID); if (result.Status != FR_Status.Success || item.CMN_STR_SCE_ForbiddenLeaveTypeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } item.CMN_BPT_STA_AbsenceReason_RefID = forbidenLeaveType.CMN_BPT_STA_AbsenceReasonID; item.CMN_STR_SCE_StructureCalendarEvent_RefID = structureEvent.CMN_STR_SCE_StructureCalendarEventID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } return(returnValue); #endregion UserCode }