protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OF_SO_1428 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Base(); var item = new ORM_CMN_STR_Office(); if (Parameter.CMN_STR_OfficeID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_STR_OfficeID); if (result.Status != FR_Status.Success || item.CMN_STR_OfficeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } var address = new ORM_CMN_Address(); if (Parameter.CMN_AddressID != Guid.Empty) { var result = address.Load(Connection, Transaction, Parameter.CMN_AddressID); if (result.Status != FR_Status.Success || address.CMN_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } address.City_Name = Parameter.City_Name; address.City_AdministrativeDistrict = Parameter.City_AdministrativeDistrict; address.City_PostalCode = Parameter.City_PostalCode; address.City_Region = Parameter.City_Region; address.Country_Name = Parameter.Country_Name; address.Province_Name = Parameter.Province_Name; address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.Tenant_RefID = securityTicket.TenantID; address.Save(Connection, Transaction); item.Default_BillingAddress_RefID = address.CMN_AddressID; item.Default_ShippingAddress_RefID = address.CMN_AddressID; item.Tenant_RefID = securityTicket.TenantID; item.Default_FaxNumber = Parameter.Default_FaxNumber; item.Default_PhoneNumber = Parameter.Default_PhoneNumber; item.Office_Name = Parameter.OfficeName; item.Office_Description = Parameter.OfficeDescription; item.Office_ShortName = Parameter.OfficeShortName; item.CMN_CAL_CalendarInstance_RefID = Parameter.CMN_CAL_CalendarInstance_RefID; item.Region_RefID = Parameter.Region_RefID; item.Country_RefID = Parameter.Country_RefID; ORM_CMN_CAL_CalendarInstance calendar = new ORM_CMN_CAL_CalendarInstance(); if (Parameter.CMN_CAL_CalendarInstance_RefID != Guid.Empty) { var result = calendar.Load(Connection, Transaction, Parameter.CMN_CAL_CalendarInstance_RefID); if (result.Status != FR_Status.Success || calendar.CMN_CAL_CalendarInstanceID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } calendar.WeekStartsOnDay = 1; calendar.Save(Connection, Transaction); item.CMN_CAL_CalendarInstance_RefID = calendar.CMN_CAL_CalendarInstanceID; item.Save(Connection, Transaction); ORM_CMN_STR_Office_2_CostCenter whereCC2OInstance = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_Office_2_CostCenter>(); whereCC2OInstance.Office_RefID = Parameter.CMN_STR_OfficeID; CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereCC2OInstance); if (Parameter.Costcenter_RefID != Guid.Empty) { var cc2o = new ORM_CMN_STR_Office_2_CostCenter(); cc2o.CostCenter_RefID = Parameter.Costcenter_RefID; cc2o.IsDefault = true; cc2o.IsDeleted = false; cc2o.Tenant_RefID = securityTicket.TenantID; cc2o.Office_RefID = item.CMN_STR_OfficeID; cc2o.Save(Connection, Transaction); } var query1 = new ORM_CMN_STR_Office_ResponsiblePerson.Query(); query1.Tenant_RefID = securityTicket.TenantID; query1.Office_RefID = item.CMN_STR_OfficeID; var res = ORM_CMN_STR_Office_ResponsiblePerson.Query.SoftDelete(Connection, Transaction, query1); if (Parameter.ResponsiblePerson != null && Parameter.ResponsiblePerson.Length > 0) { foreach (P_L5OF_SO_1428_ResponsiblePerson obj in Parameter.ResponsiblePerson) { ORM_CMN_STR_Office_ResponsiblePerson person = new ORM_CMN_STR_Office_ResponsiblePerson(); if (obj.AssignmentID != Guid.Empty) { var result = calendar.Load(Connection, Transaction, obj.AssignmentID); if (result.Status != FR_Status.Success || person.CMN_STR_Office_ResponsiblePersonID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (obj.AssignmentID != Guid.Empty) { person.IsDeleted = true; } else { person.CMN_BPT_EMP_Employee_RefID = obj.ResponsibleEmployeeID; person.Office_RefID = item.CMN_STR_OfficeID; person.Tenant_RefID = securityTicket.TenantID; } person.Save(Connection, Transaction); } } return(new FR_Guid(item.CMN_STR_OfficeID)); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OU_SOUGD_1221 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Save if (Parameter.OrgUnitID == null || Parameter.OrgUnitID == Guid.Empty) { //*******************MedicalPracticeType************************ var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.HEC_MedicalPractiseID = Guid.NewGuid(); medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.IsDeleted = false; medicalPractice.Save(Connection, Transaction); foreach (var item in Parameter.MedicalPracticeType) { var medicalPractice2PracticeType = new ORM_HEC_MedicalPractice_2_PracticeType(); medicalPractice2PracticeType.AssignmentID = Guid.NewGuid(); medicalPractice2PracticeType.HEC_MedicalPractice_Type_RefID = item.HEC_MedicalPractice_TypeID; medicalPractice2PracticeType.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPractice2PracticeType.Tenant_RefID = securityTicket.TenantID; medicalPractice2PracticeType.IsDeleted = false; medicalPractice2PracticeType.Save(Connection, Transaction); } //******************* Office************************ var Office = new ORM_CMN_STR_Office(); Office.CMN_STR_OfficeID = Guid.NewGuid(); Office.Office_Name = Parameter.OrgUnitName_DictID; Office.Tenant_RefID = securityTicket.TenantID; if (Parameter.ParentID != null && Parameter.ParentID != Guid.Empty) { Office.Parent_RefID = Parameter.ParentID; } Office.Creation_Timestamp = DateTime.Now; var officeQuery = new ORM_CMN_STR_Office.Query(); officeQuery.Tenant_RefID = securityTicket.TenantID; int officeCount = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery).Count; Office.Office_InternalNumber = String.Format("{0:00000}", officeCount + 1); Office.Default_PhoneNumber = Parameter.Telephone; Office.DisplayImage_Document_RefID = Parameter.DisplayImage_Document_RefID; Office.Default_Email = Parameter.Email; Office.Default_Website = Parameter.Website; Office.Office_Description = new Dict("cmn_str_offices"); Office.Comment = Parameter.Notes; Office.IsMedicalPractice = true; Office.IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; Office.Save(Connection, Transaction); //*******************Save Address************************ foreach (var address in Parameter.Adresses) { var Office_2_Address = new ORM_CMN_STR_Office_Address(); Office_2_Address.CMN_STR_Office_AddressID = Guid.NewGuid(); Office_2_Address.IsBillingAddress = address.IsBillingAddress; Office_2_Address.IsShippingAddress = address.IsShippingAddress; Office_2_Address.IsSpecialAddress = address.IsSpecialAddress; Office_2_Address.CMN_Address_RefID = address.AddressID; Office_2_Address.Office_RefID = Office.CMN_STR_OfficeID; Office_2_Address.Tenant_RefID = securityTicket.TenantID; Office_2_Address.Creation_Timestamp = DateTime.Now; Office_2_Address.IsDefault = address.IsDefault; Office_2_Address.Save(Connection, Transaction); var Address = new ORM_CMN_Address(); Address.CMN_AddressID = Office_2_Address.CMN_Address_RefID; Address.Tenant_RefID = securityTicket.TenantID; Address.Creation_Timestamp = DateTime.Now; Address.City_Name = address.City; Address.Street_Name = address.Street_Name; Address.Street_Number = address.Street_Number; Address.Country_ISOCode = address.CountryISO; Address.Country_Name = address.CountryName; Address.City_PostalCode = address.ZIP; if (address.IsDefault) { Address.Lattitude = address.Lattitude; Address.Longitude = address.Longitude; } Address.Save(Connection, Transaction); } //*******************Save Languages************************ foreach (var item in Parameter.SpokenLanguage) { var officeSpokenLanguages = new ORM_CMN_STR_Office_SpokenLanguage(); officeSpokenLanguages.CMN_STR_Office_SpokenLanguageID = Guid.NewGuid(); officeSpokenLanguages.Office_RefID = Office.CMN_STR_OfficeID; officeSpokenLanguages.Language_RefID = item.CMN_LanguageID; officeSpokenLanguages.IsDeleted = item.IsDeleted; officeSpokenLanguages.Tenant_RefID = securityTicket.TenantID; officeSpokenLanguages.Save(Connection, Transaction); } //*******************Save Contact Person************************ var responsiblePerson = new ORM_CMN_STR_Office_ResponsiblePerson(); responsiblePerson.CMN_STR_Office_ResponsiblePersonID = Guid.NewGuid(); responsiblePerson.Office_RefID = Office.CMN_STR_OfficeID; responsiblePerson.CMN_BPT_EMP_Employee_RefID = Guid.NewGuid(); responsiblePerson.Tenant_RefID = securityTicket.TenantID; responsiblePerson.Creation_Timestamp = DateTime.Now; responsiblePerson.Save(Connection, Transaction); var employee = new ORM_CMN_BPT_EMP_Employee(); employee.CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID; employee.BusinessParticipant_RefID = Guid.NewGuid(); employee.Creation_Timestamp = DateTime.Now; employee.Tenant_RefID = securityTicket.TenantID; employee.Save(Connection, Transaction); var businessParticpant = new ORM_CMN_BPT_BusinessParticipant(); businessParticpant.CMN_BPT_BusinessParticipantID = employee.BusinessParticipant_RefID; businessParticpant.IsNaturalPerson = true; businessParticpant.DisplayName = Parameter.ContactPerson.Title + " " + Parameter.ContactPerson.FirstName + " " + Parameter.ContactPerson.LastName; businessParticpant.Tenant_RefID = securityTicket.TenantID; businessParticpant.Creation_Timestamp = DateTime.Now; businessParticpant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); businessParticpant.Save(Connection, Transaction); var personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = businessParticpant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo.Title = Parameter.ContactPerson.Title; personInfo.FirstName = Parameter.ContactPerson.FirstName; personInfo.LastName = Parameter.ContactPerson.LastName; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Save(Connection, Transaction); //*******************AppointmentType************************ foreach (var item in Parameter.AppoitmentType) { ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability orgUnitToAppointmentType = new ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability(); orgUnitToAppointmentType.PPS_TSK_Task_Template_OrganizationalUnitAvailabilityID = Guid.NewGuid(); orgUnitToAppointmentType.CMN_STR_Office_RefID = Office.CMN_STR_OfficeID; orgUnitToAppointmentType.PPS_TSK_Task_Template_RefID = item.PPS_TSK_Task_Template_RefID; orgUnitToAppointmentType.Creation_Timestamp = DateTime.Now; orgUnitToAppointmentType.Tenant_RefID = securityTicket.TenantID; orgUnitToAppointmentType.Save(Connection, Transaction); } returnValue.Result = Office.CMN_STR_OfficeID; } #endregion #region Delete else if (Parameter.IsDeleted) { List <Guid> guidList = new List <Guid>(); guidList.Add(Parameter.OrgUnitID); cls_Delete_OrgsUnitsGeneralData.Invoke(Connection, Transaction, new P_L5OU_DOUGD_1221 { OrgUnitID = guidList.ToArray() }, securityTicket); } #endregion #region Edit else { var officeQuery = new ORM_CMN_STR_Office.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_STR_OfficeID = Parameter.OrgUnitID }; var office = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery).Single(); office.Office_Name = Parameter.OrgUnitName_DictID; office.Default_PhoneNumber = Parameter.Telephone; office.DisplayImage_Document_RefID = Parameter.DisplayImage_Document_RefID; office.Default_Email = Parameter.Email; office.Comment = Parameter.Notes; office.Default_Website = Parameter.Website; if (Parameter.ParentID != null && Parameter.ParentID != Guid.Empty) { office.Parent_RefID = Parameter.ParentID; } office.IsMedicalPractice = true; office.Save(Connection, Transaction); //*******************Medical practice type************************ var medicalPractice2TypeQuery = new ORM_HEC_MedicalPractice_2_PracticeType.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_MedicalPractice_RefID = office.IfMedicalPractise_HEC_MedicalPractice_RefID }; var medicalPractice2Type = ORM_HEC_MedicalPractice_2_PracticeType.Query.Search(Connection, Transaction, medicalPractice2TypeQuery).ToList(); foreach (var item in Parameter.MedicalPracticeType) { if (item.IsDeleted) { foreach (var medicalPractice2TypeItem in medicalPractice2Type) { if (medicalPractice2TypeItem.HEC_MedicalPractice_Type_RefID == item.HEC_MedicalPractice_TypeID) { medicalPractice2TypeItem.Tenant_RefID = securityTicket.TenantID; if (office.IfMedicalPractise_HEC_MedicalPractice_RefID != Guid.Empty) { medicalPractice2TypeItem.HEC_MedicalPractice_RefID = office.IfMedicalPractise_HEC_MedicalPractice_RefID; } else { var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.HEC_MedicalPractiseID = Guid.NewGuid(); medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.IsDeleted = false; medicalPractice.Save(Connection, Transaction); office.IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; office.Save(Connection, Transaction); medicalPractice2TypeItem.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; } medicalPractice2TypeItem.IsDeleted = true; medicalPractice2TypeItem.Save(Connection, Transaction); break; } } } else { ORM_HEC_MedicalPractice_2_PracticeType medPracticeType = null; foreach (var medicalPractice2TypeItem in medicalPractice2Type) { if (medicalPractice2TypeItem.HEC_MedicalPractice_Type_RefID == item.HEC_MedicalPractice_TypeID) { medPracticeType = medicalPractice2TypeItem; if (medPracticeType.HEC_MedicalPractice_RefID == Guid.Empty) { var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.HEC_MedicalPractiseID = Guid.NewGuid(); medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.IsDeleted = false; medicalPractice.Save(Connection, Transaction); office.IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; office.Save(Connection, Transaction); medPracticeType.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medPracticeType.Save(Connection, Transaction); } break; } } if (medPracticeType == null) { medPracticeType = new ORM_HEC_MedicalPractice_2_PracticeType(); medPracticeType.Tenant_RefID = securityTicket.TenantID; medPracticeType.IsDeleted = false; medPracticeType.HEC_MedicalPractice_Type_RefID = item.HEC_MedicalPractice_TypeID; if (office.IfMedicalPractise_HEC_MedicalPractice_RefID != Guid.Empty) { medPracticeType.HEC_MedicalPractice_RefID = office.IfMedicalPractise_HEC_MedicalPractice_RefID; } else { var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.HEC_MedicalPractiseID = Guid.NewGuid(); medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.IsDeleted = false; medicalPractice.Save(Connection, Transaction); office.IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; office.Save(Connection, Transaction); medPracticeType.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; } medPracticeType.Save(Connection, Transaction); } else { if (medPracticeType.IsDeleted) { medPracticeType.Tenant_RefID = securityTicket.TenantID; medPracticeType.IsDeleted = true; if (office.IfMedicalPractise_HEC_MedicalPractice_RefID != Guid.Empty) { medPracticeType.HEC_MedicalPractice_RefID = office.IfMedicalPractise_HEC_MedicalPractice_RefID; } else { var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.HEC_MedicalPractiseID = Guid.NewGuid(); medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.IsDeleted = false; medicalPractice.Save(Connection, Transaction); office.IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; office.Save(Connection, Transaction); medPracticeType.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; } medPracticeType.Save(Connection, Transaction); } } } } //*******************Save Spoken Languages************************ var office_spoken_languages = new ORM_CMN_STR_Office_SpokenLanguage.Query() { Tenant_RefID = securityTicket.TenantID, Office_RefID = office.CMN_STR_OfficeID, IsDeleted = false }; var officeSpokenLanguageQuery = ORM_CMN_STR_Office_SpokenLanguage.Query.Search(Connection, Transaction, office_spoken_languages); foreach (var item in Parameter.SpokenLanguage) { ORM_CMN_STR_Office_SpokenLanguage officeSpokenLang = null; foreach (var officeSpokenLanguageItem in officeSpokenLanguageQuery) { if (officeSpokenLanguageItem.Language_RefID == item.CMN_LanguageID && officeSpokenLanguageItem.Office_RefID == office.CMN_STR_OfficeID) { officeSpokenLang = officeSpokenLanguageItem; break; } } if (officeSpokenLang == null) { var officeSpokenLanguage = new ORM_CMN_STR_Office_SpokenLanguage(); officeSpokenLanguage.CMN_STR_Office_SpokenLanguageID = Guid.NewGuid(); officeSpokenLanguage.Language_RefID = item.CMN_LanguageID; officeSpokenLanguage.IsDeleted = item.IsDeleted; officeSpokenLanguage.Office_RefID = office.CMN_STR_OfficeID; officeSpokenLanguage.Tenant_RefID = securityTicket.TenantID; officeSpokenLanguage.Save(Connection, Transaction); } else { officeSpokenLang.Language_RefID = item.CMN_LanguageID; officeSpokenLang.IsDeleted = item.IsDeleted; officeSpokenLang.Save(Connection, Transaction); } } //*******************Save Address************************ foreach (var address in Parameter.Adresses) { var Office_2_Address = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, new ORM_CMN_STR_Office_Address.Query() { IsBillingAddress = address.IsBillingAddress, IsShippingAddress = address.IsShippingAddress, IsSpecialAddress = address.IsSpecialAddress, Office_RefID = office.CMN_STR_OfficeID, Tenant_RefID = securityTicket.TenantID, CMN_Address_RefID = address.AddressID, IsDeleted = false }).SingleOrDefault(); if (Office_2_Address == null) { Office_2_Address = new ORM_CMN_STR_Office_Address(); Office_2_Address.CMN_STR_Office_AddressID = Guid.NewGuid(); Office_2_Address.IsBillingAddress = address.IsBillingAddress; Office_2_Address.IsShippingAddress = address.IsShippingAddress; Office_2_Address.IsSpecialAddress = address.IsSpecialAddress; Office_2_Address.CMN_Address_RefID = address.AddressID; Office_2_Address.Office_RefID = office.CMN_STR_OfficeID; Office_2_Address.Tenant_RefID = securityTicket.TenantID; Office_2_Address.Creation_Timestamp = DateTime.Now; } Office_2_Address.IsDefault = address.IsDefault; var Address = ORM_CMN_Address.Query.Search(Connection, Transaction, new ORM_CMN_Address.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_AddressID = Office_2_Address.CMN_Address_RefID }).SingleOrDefault(); if (Address == null) { Address = new ORM_CMN_Address(); Address.CMN_AddressID = Office_2_Address.CMN_Address_RefID; Address.Tenant_RefID = securityTicket.TenantID; Address.Creation_Timestamp = DateTime.Now; } if (address.IsDeleted) { Address.IsDeleted = true; Office_2_Address.IsDeleted = true; } else { Address.City_Name = address.City; Address.Street_Name = address.Street_Name; Address.Street_Number = address.Street_Number; Address.Country_ISOCode = address.CountryISO; Address.Country_Name = address.CountryName; Address.City_PostalCode = address.ZIP; if (address.IsDefault) { Address.Lattitude = address.Lattitude; Address.Longitude = address.Longitude; } } Office_2_Address.Save(Connection, Transaction); Address.Save(Connection, Transaction); } //*******************AppointmentType************************ foreach (var item in Parameter.AppoitmentType) { var orgUnitToAppointmentTypeQuery = new ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability.Query(); orgUnitToAppointmentTypeQuery.CMN_STR_Office_RefID = Parameter.OrgUnitID; orgUnitToAppointmentTypeQuery.PPS_TSK_Task_Template_RefID = item.PPS_TSK_Task_Template_RefID; orgUnitToAppointmentTypeQuery.Tenant_RefID = securityTicket.TenantID; orgUnitToAppointmentTypeQuery.IsDeleted = false; var orgUnitToAppointmentType = ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability.Query.Search(Connection, Transaction, orgUnitToAppointmentTypeQuery).SingleOrDefault(); if (orgUnitToAppointmentType == null) { if (!item.IsDeleted) { orgUnitToAppointmentType = new ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability(); orgUnitToAppointmentType.PPS_TSK_Task_Template_OrganizationalUnitAvailabilityID = Guid.NewGuid(); orgUnitToAppointmentType.CMN_STR_Office_RefID = Parameter.OrgUnitID; orgUnitToAppointmentType.PPS_TSK_Task_Template_RefID = item.PPS_TSK_Task_Template_RefID; orgUnitToAppointmentType.Creation_Timestamp = DateTime.Now; orgUnitToAppointmentType.Tenant_RefID = securityTicket.TenantID; orgUnitToAppointmentType.Save(Connection, Transaction); } } else { if (item.IsDeleted) { orgUnitToAppointmentType.IsDeleted = true; orgUnitToAppointmentType.Save(Connection, Transaction); } } } //*******************Save Contact Person************************ var responsiblePerson = ORM_CMN_STR_Office_ResponsiblePerson.Query.Search(Connection, Transaction, new ORM_CMN_STR_Office_ResponsiblePerson.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Office_RefID = office.CMN_STR_OfficeID }).Single(); var employee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID }).Single(); var businessParticpant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_BPT_BusinessParticipantID = employee.BusinessParticipant_RefID }).Single(); businessParticpant.DisplayName = Parameter.ContactPerson.Title + " " + Parameter.ContactPerson.FirstName + " " + Parameter.ContactPerson.LastName; businessParticpant.Save(Connection, Transaction); var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_PER_PersonInfoID = businessParticpant.IfNaturalPerson_CMN_PER_PersonInfo_RefID }).Single(); personInfo.Title = Parameter.ContactPerson.Title; personInfo.FirstName = Parameter.ContactPerson.FirstName; personInfo.LastName = Parameter.ContactPerson.LastName; personInfo.Save(Connection, Transaction); returnValue.Result = office.CMN_STR_OfficeID; } #endregion return(returnValue); #endregion UserCode }