protected static FR_L3MD_GDwPfT_1404_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3MD_GDwPfT_1404_Array(); var basicInfos = cls_Get_Doctor_BaseInfo_withPractice_forTenant.Invoke(Connection, Transaction, securityTicket).Result; var accs = cls_Retrive_Account_Code_Details_forTenant.Invoke(Connection, Transaction, securityTicket).Result; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Tenant_RefID = securityTicket.TenantID; customerQuery.IsDeleted = false; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.IsDeleted = false; var cust2SalesRespRes = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery); List <L3MD_GDwPfT_1404> retVal = new List <L3MD_GDwPfT_1404>(); foreach (var item in basicInfos) { var doc = new L3MD_GDwPfT_1404(); doc.BaseInfo = item; if (item.Account_RefID != Guid.Empty) { var accountInfo = accs.FirstOrDefault(a => a.BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID); if (accountInfo != null) { doc.AccountInfo = new L3MD_GDwPfT_1404_AccountInfo(); doc.AccountInfo.AccountCode_ValidFrom = accountInfo.AccountCode_ValidFrom; doc.AccountInfo.AccountCode_Value = accountInfo.AccountCode_Value; doc.AccountInfo.USR_AccountID = accountInfo.Account_RefID; doc.AccountInfo.USR_Device_AccountCodeID = accountInfo.USR_Device_AccountCodeID; } var customer = customerRes.FirstOrDefault(c => c.Ext_BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID); if (customer != null) { var c2SalesResp = cust2SalesRespRes.FirstOrDefault(sr => sr.Customer_RefID == customer.CMN_BPT_CTM_CustomerID); if (c2SalesResp != null) { doc.SalesRepresentative = new L3MD_GDwPfT_1404_SalesRepresentative(); doc.SalesRepresentative.SalesRepresentative_RefID = c2SalesResp.SalesRepresentative_RefID; } } } retVal.Add(doc); } returnValue.Result = retVal.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5OD_GLDfT_1111_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5OD_GLDfT_1111_Array(); var basicInfos = cls_Get_Doctor_BaseInfo_forTenant.Invoke(Connection, Transaction, securityTicket).Result; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Tenant_RefID = securityTicket.TenantID; var customers = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); var customer2SRQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); customer2SRQuery.Tenant_RefID = securityTicket.TenantID; var customer2SRs = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, customer2SRQuery); List <L5OD_GLDfT_1111> retVal = new List <L5OD_GLDfT_1111>(); foreach (var item in basicInfos) { var doc = new L5OD_GLDfT_1111(); doc.BaseInfo = item; doc.FirstName = item.FirstName; doc.LastName = item.LastName; doc.HEC_DoctorID = item.HEC_DoctorID; doc.Title = item.Title; var customer = customers.FirstOrDefault(c => c.Ext_BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID); if (customer != null) { var c2sr = customer2SRs.FirstOrDefault(c => c.Customer_RefID == customer.CMN_BPT_CTM_CustomerID); if (c2sr != null) { doc.SalesRepresentative = new L5OD_GLDfT_1111_SalesRepresentative(); doc.SalesRepresentative.SalesRepresentative_RefID = c2sr.SalesRepresentative_RefID; } } retVal.Add(doc); } returnValue.Result = retVal.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5OD_GDfT_1126_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5OD_GDfT_1126_Array(); var basicInfos = cls_Get_Doctor_BaseInfo_withPractice_forTenant.Invoke(Connection, Transaction, securityTicket).Result; var allPractices = cls_Get_Practice_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; var accs = cls_Retrive_Account_Code_Details_forTenant.Invoke(Connection, Transaction, securityTicket).Result; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Tenant_RefID = securityTicket.TenantID; var customers = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); var customer2SRQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); customer2SRQuery.Tenant_RefID = securityTicket.TenantID; var customer2SRs = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, customer2SRQuery); List <L5OD_GDfT_1126> retVal = new List <L5OD_GDfT_1126>(); foreach (var item in basicInfos) { var doc = new L5OD_GDfT_1126(); doc.BaseInfo = item; doc.FirstName = item.FirstName; doc.LastName = item.LastName; doc.HEC_DoctorID = item.HEC_DoctorID; doc.Title = item.Title; if (item.AllPractices != null) { var practices = item.AllPractices.OrderBy(p => p.Creation_Timestamp); var doctorsPractice = practices.FirstOrDefault(); if (doctorsPractice != null) { var practicesForDoctor = allPractices.FirstOrDefault(p => p.BaseInfo.HEC_MedicalPractiseID == doctorsPractice.PracticeID); if (practicesForDoctor != null) { L5OD_GDfT_1126_Practice practice = new L5OD_GDfT_1126_Practice(); practice.AssociatedParticipant_FunctionName = doctorsPractice.AssociatedParticipant_FunctionName; practice.CMN_BPT_BusinessParticipantID = doctorsPractice.CMN_BPT_BusinessParticipantID; if (practicesForDoctor.OtherOphthal_PracticeData != null) { practice.HealthAssociation_Name = practicesForDoctor.OtherOphthal_PracticeData.HealthAssociation_Name; } practice.PracticeID = practicesForDoctor.BaseInfo.HEC_MedicalPractiseID; practice.PracticeName = practicesForDoctor.BaseInfo.PracticeName; practice.Region_Name = practicesForDoctor.BaseInfo.Region_Name; practice.Street_Name = practicesForDoctor.BaseInfo.Street_Name; practice.Street_Number = practicesForDoctor.BaseInfo.Street_Number; practice.Town = practicesForDoctor.BaseInfo.Town; practice.ZIP = practicesForDoctor.BaseInfo.ZIP; doc.Practice = practice; } } var customer = customers.FirstOrDefault(c => c.Ext_BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID); if (customer != null) { var c2sr = customer2SRs.FirstOrDefault(c => c.Customer_RefID == customer.CMN_BPT_CTM_CustomerID); if (c2sr != null) { doc.SalesRepresentative = new L5OD_GDfT_1126_SalesRepresentative(); doc.SalesRepresentative.SalesRepresentative_RefID = c2sr.SalesRepresentative_RefID; } } var accountInfo = accs.FirstOrDefault(a => a.BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID); if (accountInfo != null) { doc.AccountInfo = new L5OD_GDfT_1126_AccountInfo(); doc.AccountInfo.AccountCode_Value = accountInfo.AccountCode_Value; } } retVal.Add(doc); } returnValue.Result = retVal.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OD_SD_1130 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); Guid accounrRefID = Guid.Empty; var doctorQuery = new ORM_HEC_Doctor.Query(); ORM_HEC_Doctor doctor; if (Parameter.HEC_DoctorID != Guid.Empty) { doctorQuery.HEC_DoctorID = Parameter.HEC_DoctorID; doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First(); accounrRefID = doctor.Account_RefID; } P_L3MD_SDBI_1349 sbdParam = new P_L3MD_SDBI_1349(); sbdParam.DoctorID = Parameter.HEC_DoctorID; sbdParam.Account_RefID = accounrRefID; sbdParam.FirstName = Parameter.FirstName; sbdParam.LastName = Parameter.LastName; sbdParam.isOphthalSave = true; sbdParam.ifOphthal_Salutation_General = Parameter.Salutation_General; sbdParam.ifOphthal_Salutation_Letter = Parameter.Salutation_Letter; sbdParam.Title = Parameter.Title; List <P_L3MD_SDBI_1349_Contacts> contactsParams = new List <P_L3MD_SDBI_1349_Contacts>(); if (Parameter.Contacts != null) { foreach (var item in Parameter.Contacts) { var c = new P_L3MD_SDBI_1349_Contacts(); c.CMN_PER_CommunicationContact_TypeID = item.CMN_PER_CommunicationContact_TypeID; c.Content = item.Content; contactsParams.Add(c); } } sbdParam.Contacts = contactsParams.ToArray(); List <P_L3MD_SDBI_1349_Practice> practicesParams = new List <P_L3MD_SDBI_1349_Practice>(); if (Parameter.Practices != null) { foreach (var item in Parameter.Practices) { var p = new P_L3MD_SDBI_1349_Practice(); p.PracticeID = item.PracticeID; p.isDeleted = item.isDeleted; p.AssociatedParticipant_FunctionName = item.AssociatedParticipant_FunctionName; practicesParams.Add(p); } } sbdParam.Practices = practicesParams.ToArray(); var docID = cls_Save_Doctor_BaseInfo.Invoke(Connection, Transaction, sbdParam, securityTicket).Result; doctorQuery = new ORM_HEC_Doctor.Query(); doctorQuery.HEC_DoctorID = docID; doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First(); var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQuery.CMN_BPT_BusinessParticipantID = doctor.BusinessParticipant_RefID; var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery).First(); ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative SalesRepresentative; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).FirstOrDefault(); if (customer == null) { customer = new ORM_CMN_BPT_CTM_Customer(); customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.Tenant_RefID = securityTicket.TenantID; SalesRepresentative = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative(); SalesRepresentative.AssignmentID = Guid.NewGuid(); SalesRepresentative.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; SalesRepresentative.Tenant_RefID = securityTicket.TenantID; customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; } else { customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First(); var SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); SalesRepresentativeQuery.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; SalesRepresentative = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, SalesRepresentativeQuery).First(); } SalesRepresentative.SalesRepresentative_RefID = Parameter.CMN_BPT_SalesRepresentativeID; var sRepresentativeQuery = new ORM_CMN_BPT_SalesRepresentative.Query(); sRepresentativeQuery.CMN_BPT_SalesRepresentativeID = Parameter.CMN_BPT_SalesRepresentativeID; sRepresentativeQuery.IsDeleted = false; var sRepresentative = ORM_CMN_BPT_SalesRepresentative.Query.Search(Connection, Transaction, sRepresentativeQuery).FirstOrDefault(); if (sRepresentative == null) { sRepresentative = new ORM_CMN_BPT_SalesRepresentative(); sRepresentative.CMN_BPT_SalesRepresentativeID = Parameter.CMN_BPT_SalesRepresentativeID; sRepresentative.Save(Connection, Transaction); } customer.Save(Connection, Transaction); SalesRepresentative.Save(Connection, Transaction); ORM_USR_Account account; ORM_USR_Device_AccountCode code; ORM_USR_Device_AccountCode_StatusHistory codeStatus; var accountQuery = new ORM_USR_Account.Query(); accountQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; accountQuery.AccountType = 3; var accountQueryRes = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery); if (accountQueryRes.Count == 0) { account = new ORM_USR_Account(); account.USR_AccountID = Guid.NewGuid(); account.Tenant_RefID = securityTicket.TenantID; account.AccountType = 3; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.Save(Connection, Transaction); code = new ORM_USR_Device_AccountCode(); code.Tenant_RefID = securityTicket.TenantID; code.USR_Device_AccountCodeID = Guid.NewGuid(); code.Account_RefID = account.USR_AccountID; code.AccountCode_ValidFrom = DateTime.Now; codeStatus = new ORM_USR_Device_AccountCode_StatusHistory(); codeStatus.USR_Device_AccountCode_StatusHistoryID = Guid.NewGuid(); codeStatus.Device_AccountCode_RefID = code.USR_Device_AccountCodeID; codeStatus.Tenant_RefID = securityTicket.TenantID; codeStatus.IsAccountCode_Active = true; codeStatus.Save(Connection, Transaction); code.AccountCode_CurrentStatus_RefID = codeStatus.USR_Device_AccountCode_StatusHistoryID; L3DAC_GDACFTCV_1616 checkCodeValue; P_L3DAC_GDACFTCV_1616 codeParam = new P_L3DAC_GDACFTCV_1616(); string codeValue; do { codeValue = RandomString.Generate(8); codeParam.CodeValue = codeValue; checkCodeValue = cls_GetDeviceAccountCodeForTenantAndCodeValue.Invoke(Connection, Transaction, codeParam, securityTicket).Result; } while (checkCodeValue != null); code.AccountCode_Value = codeValue; code.Save(Connection, Transaction); } returnValue.Result = docID; return(returnValue); #endregion UserCode }
protected static FR_L5MD_GDwPfID_1414 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MD_GDwPfID_1414 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5MD_GDwPfID_1414(); P_L3MD_GDBIfID_1150 biParam = new P_L3MD_GDBIfID_1150(); biParam.DoctorID = Parameter.DoctorID; var baseInfo = cls_Get_Doctor_BaseInfo_byID.Invoke(Connection, Transaction, biParam, securityTicket).Result; returnValue.Result = new L5MD_GDwPfID_1414(); returnValue.Result.BaseInfo = baseInfo; P_L3DAC_RACDbBPID_1056 aiParam = new P_L3DAC_RACDbBPID_1056(); aiParam.BPrticipantID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; var accInfo = cls_Retrive_Account_Code_Details_byBParticipantID.Invoke(Connection, Transaction, aiParam, securityTicket).Result; if (accInfo != null) { var AccountInfo = new L5MD_GDwPfID_1414_AccountInfo(); AccountInfo.AccountCode_ValidFrom = accInfo.AccountCode_ValidFrom; AccountInfo.AccountCode_Value = accInfo.AccountCode_Value; AccountInfo.USR_AccountID = baseInfo.Account_RefID; AccountInfo.USR_Device_AccountCodeID = accInfo.USR_Device_AccountCodeID; returnValue.Result.AccountInfo = AccountInfo; } var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; customerQuery.IsDeleted = false; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count > 0) { var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.Customer_RefID = customerRes.First().CMN_BPT_CTM_CustomerID; ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.IsDeleted = false; var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative1 = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery).First(); returnValue.Result.SalesRepresentative = new L5MD_GDwPfID_1414_SalesRepresentative(); returnValue.Result.SalesRepresentative.SalesRepresentative_RefID = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative1.SalesRepresentative_RefID; } var assocBPQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); assocBPQuery.BusinessParticipant_RefID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; assocBPQuery.IsDeleted = false; var assocBPQs = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, assocBPQuery).ToArray(); if (assocBPQs.Length > 0) { assocBPQs = assocBPQs.OrderBy(a => a.Creation_Timestamp).ToArray(); var assocBPQ = assocBPQs.First(); var practiceBPQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); practiceBPQuery.CMN_BPT_BusinessParticipantID = assocBPQ.AssociatedBusinessParticipant_RefID; var practiceBP = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, practiceBPQuery).First(); var companInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companInfoQuery.CMN_COM_CompanyInfoID = practiceBP.IfCompany_CMN_COM_CompanyInfo_RefID; var companInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companInfoQuery).First(); var practiceQuery = new ORM_HEC_MedicalPractis.Query(); practiceQuery.Ext_CompanyInfo_RefID = companInfo.CMN_COM_CompanyInfoID; var prac = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practiceQuery).First(); P_L3MP_GPfID_1222 pbiParam = new P_L3MP_GPfID_1222(); pbiParam.HEC_MedicalPractiseID = prac.HEC_MedicalPractiseID; var practiceBasInfo = cls_Get_Practice_For_ID.Invoke(Connection, Transaction, pbiParam, securityTicket).Result; if (practiceBasInfo != null) { L5MD_GDwPfID_1414_Practice practice = new L5MD_GDwPfID_1414_Practice(); practice.AssociatedParticipant_FunctionName = assocBPQ.AssociatedParticipant_FunctionName; practice.CMN_BPT_BusinessParticipantID = practiceBasInfo.BaseInfo.CMN_BPT_BusinessParticipantID; if (practiceBasInfo.OtherOphthal_PracticeData != null) { practice.HealthAssociation_Name = practiceBasInfo.OtherOphthal_PracticeData.HealthAssociation_Name; } practice.PracticeID = practiceBasInfo.BaseInfo.HEC_MedicalPractiseID; practice.PracticeName = practiceBasInfo.BaseInfo.PracticeName; practice.Region_Name = practiceBasInfo.BaseInfo.Region_Name; practice.Street_Name = practiceBasInfo.BaseInfo.Street_Name; practice.Street_Number = practiceBasInfo.BaseInfo.Street_Number; practice.Town = practiceBasInfo.BaseInfo.Town; practice.ZIP = practiceBasInfo.BaseInfo.ZIP; returnValue.Result.Practice = practice; } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MD_DDbID_1031 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var doctor = new ORM_HEC_Doctor(); if (Parameter.DoctorID != Guid.Empty) { var result = doctor.Load(Connection, Transaction, Parameter.DoctorID); if (result.Status != FR_Status.Success || doctor.HEC_DoctorID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } doctor.IsDeleted = true; doctor.Save(Connection, Transaction); //bussinessParticipant var query1 = new ORM_CMN_BPT_BusinessParticipant.Query(); query1.CMN_BPT_BusinessParticipantID = doctor.BusinessParticipant_RefID; var bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query1).First(); bussinessParticipant.IsDeleted = true; bussinessParticipant.Save(Connection, Transaction); if (doctor.Account_RefID != Guid.Empty) { var account2personInfoQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); account2personInfoQuery.USR_Account_RefID = doctor.Account_RefID; account2personInfoQuery.Tenant_RefID = securityTicket.TenantID; var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, account2personInfoQuery).FirstOrDefault(); if (account2personInfo != null) { account2personInfo.IsDeleted = true; account2personInfo.Save(Connection, Transaction); var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query2).First(); personInfo.IsDeleted = true; personInfo.Save(Connection, Transaction); } var query4 = new ORM_CMN_PER_CommunicationContact.Query(); query4.PersonInfo_RefID = bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var communicationContactsList = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query4).ToList(); foreach (var contact in communicationContactsList) { contact.IsDeleted = true; contact.Save(Connection, Transaction); } } var query3 = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); query3.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; query3.IsDeleted = false; var abpRes = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, query3); foreach (ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant assigned in abpRes) { assigned.IsDeleted = true; assigned.Save(Connection, Transaction); } #endregion ORM_CMN_BPT_CTM_Customer customer; ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative SalesRepresentative; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count != 0) { customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First(); var SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); SalesRepresentativeQuery.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; SalesRepresentative = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, SalesRepresentativeQuery).First(); customer.IsDeleted = true; customer.Save(Connection, Transaction); SalesRepresentative.IsDeleted = true; SalesRepresentative.Save(Connection, Transaction); } var accountQuery = new ORM_USR_Account.Query(); accountQuery.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; accountQuery.AccountType = 3; var accountQueryRes = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery); if (accountQueryRes.Count != 0) { var account = accountQueryRes.First(); account.IsDeleted = true; account.Save(Connection, Transaction); var codeQuery = new ORM_USR_Device_AccountCode.Query(); codeQuery.Account_RefID = account.USR_AccountID; var code = ORM_USR_Device_AccountCode.Query.Search(Connection, Transaction, codeQuery).First(); code.IsDeleted = true; code.Save(Connection, Transaction); var codeStatusQuery = new ORM_USR_Device_AccountCode_StatusHistory.Query(); codeStatusQuery.Device_AccountCode_RefID = code.USR_Device_AccountCodeID; var codeStatus = ORM_USR_Device_AccountCode_StatusHistory.Query.Search(Connection, Transaction, codeStatusQuery).First(); codeStatus.IsDeleted = true; codeStatus.Save(Connection, Transaction); } } returnValue.Result = doctor.HEC_DoctorID; return(returnValue); }