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

            var queryOfficeToDelete = new ORM_CMN_STR_Office.Query();
            queryOfficeToDelete.CMN_STR_OfficeID = Parameter.OfficeID;
            queryOfficeToDelete.Tenant_RefID     = securityTicket.TenantID;
            queryOfficeToDelete.IsDeleted        = false;
            var OfficeToDelete = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, queryOfficeToDelete).SingleOrDefault();

            if (OfficeToDelete != null)
            {
                var param = new P_L2O_SO_1529();
                param.CMN_STR_OfficeID = Parameter.OfficeID;
                param.IsDeleted        = true;

                var queryOfficeAddresses = new ORM_CMN_STR_Office_Address.Query();
                queryOfficeAddresses.Office_RefID = Parameter.OfficeID;
                queryOfficeAddresses.Tenant_RefID = securityTicket.TenantID;
                queryOfficeAddresses.IsDeleted    = false;

                //Locate all office addresses using connection table
                var OfficeAddresses = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, queryOfficeAddresses);

                foreach (var officeAddress in OfficeAddresses)
                {
                    var deleteAddressParam = new P_L2AD_SA_1755();
                    deleteAddressParam.CMN_AddressID = officeAddress.CMN_Address_RefID;
                    deleteAddressParam.IsDeleted     = true;
                    cls_Save_Address.Invoke(Connection, Transaction, deleteAddressParam);
                }

                cls_Save_Office.Invoke(Connection, Transaction, param);
            }

            var queryChildrenOfficesToDelete = new ORM_CMN_STR_Office.Query();
            queryChildrenOfficesToDelete.Parent_RefID = Parameter.OfficeID;
            queryChildrenOfficesToDelete.Tenant_RefID = securityTicket.TenantID;
            queryChildrenOfficesToDelete.IsDeleted    = false;
            var ChildrenOfficesToDelete = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, queryChildrenOfficesToDelete);

            if (ChildrenOfficesToDelete.Count > 0)
            {
                foreach (var childrenOffice in ChildrenOfficesToDelete)
                {
                    var deleteChildrenOfficeParam = new P_L5OF_DOD_1520();
                    deleteChildrenOfficeParam.OfficeID = childrenOffice.CMN_STR_OfficeID;
                    cls_Delete_Office_Deep.Invoke(Connection, Transaction, deleteChildrenOfficeParam, securityTicket);
                }
            }


            return(returnValue);

            #endregion UserCode
        }
Пример #2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2OF_SOA_1410 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            if (Parameter.IsDefaultAddress)
            {
                //set previous flags as non default
                ORM_CMN_STR_Office_Address.Query.Update(Connection, Transaction,
                                                        new ORM_CMN_STR_Office_Address.Query()
                {
                    Office_RefID      = Parameter.OfficeID,
                    IsDefault         = true,
                    IsShippingAddress = Parameter.IsShippingAddress,
                    IsBillingAddress  = Parameter.IsBillingAddress
                },
                                                        new ORM_CMN_STR_Office_Address.Query()
                {
                    IsDefault = false
                }
                                                        );
            }

            var addressID = Guid.Empty;
            if (Parameter.AddressID == Guid.Empty)
            {
                //Create
                var saveAddressParam = new P_L2AD_SA_1755();
                saveAddressParam.CMN_AddressID   = Parameter.Address_Save.CMN_AddressID;
                saveAddressParam.CareOf          = Parameter.Address_Save.CareOf;
                saveAddressParam.Street_Name     = Parameter.Address_Save.Street_Name;
                saveAddressParam.Street_Number   = Parameter.Address_Save.Street_Number;
                saveAddressParam.City_PostalCode = Parameter.Address_Save.City_PostalCode;
                saveAddressParam.City_Name       = Parameter.Address_Save.City_Name;
                saveAddressParam.Country_Name    = Parameter.Address_Save.Country_Name;
                saveAddressParam.Country_ISOCode = Parameter.Address_Save.Country_ISOCode;
                addressID = cls_Save_Address.Invoke(Connection, Transaction, saveAddressParam, securityTicket).Result;

                var OfficeAddress = new ORM_CMN_STR_Office_Address();

                OfficeAddress.CMN_Address_RefID     = addressID;
                OfficeAddress.Office_RefID          = Parameter.OfficeID;
                OfficeAddress.IsBillingAddress      = Parameter.IsBillingAddress;
                OfficeAddress.IsShippingAddress     = Parameter.IsShippingAddress;
                OfficeAddress.IsSpecialAddress      = Parameter.IsSpecialAddress;
                OfficeAddress.IfSpecialAddress_Name = Parameter.IsSpecialAddress_Name;
                OfficeAddress.IsDefault             = Parameter.IsDefaultAddress;
                OfficeAddress.Tenant_RefID          = securityTicket.TenantID;
                OfficeAddress.Save(Connection, Transaction);
            }
            else
            {
                //Update
                addressID = Parameter.AddressID;

                var address = new ORM_CMN_Address();
                address.Load(Connection, Transaction, Parameter.AddressID);
                address.CareOf          = Parameter.Address_Save.CareOf;
                address.Street_Name     = Parameter.Address_Save.Street_Name;
                address.Street_Number   = Parameter.Address_Save.Street_Number;
                address.City_PostalCode = Parameter.Address_Save.City_PostalCode;
                address.City_Name       = Parameter.Address_Save.City_Name;
                address.Country_Name    = Parameter.Address_Save.Country_Name;
                address.Country_ISOCode = Parameter.Address_Save.Country_ISOCode;
                address.Save(Connection, Transaction);

                var queryOfficeAddress = new ORM_CMN_STR_Office_Address.Query();
                queryOfficeAddress.CMN_Address_RefID = Parameter.AddressID;
                queryOfficeAddress.Office_RefID      = Parameter.OfficeID;
                queryOfficeAddress.IsDeleted         = false;
                var officeAddress = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, queryOfficeAddress).FirstOrDefault();

                officeAddress.IsDefault             = Parameter.IsDefaultAddress;
                officeAddress.IsBillingAddress      = Parameter.IsBillingAddress;
                officeAddress.IsShippingAddress     = Parameter.IsShippingAddress;
                officeAddress.IsSpecialAddress      = Parameter.IsSpecialAddress;
                officeAddress.IfSpecialAddress_Name = Parameter.IsSpecialAddress_Name;

                officeAddress.Save(Connection, Transaction);
            }


            #region Update DefaultAdresses

            var defaultShippingAddressQuery = new ORM_CMN_STR_Office_Address.Query();
            defaultShippingAddressQuery.Office_RefID      = Parameter.OfficeID;
            defaultShippingAddressQuery.IsDeleted         = false;
            defaultShippingAddressQuery.IsDefault         = true;
            defaultShippingAddressQuery.IsShippingAddress = true;
            var defaultShippingAddress = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, defaultShippingAddressQuery).SingleOrDefault();

            var defaultBillingAddressQuery = new ORM_CMN_STR_Office_Address.Query();
            defaultBillingAddressQuery.Office_RefID     = Parameter.OfficeID;
            defaultBillingAddressQuery.IsDeleted        = false;
            defaultBillingAddressQuery.IsDefault        = true;
            defaultBillingAddressQuery.IsBillingAddress = true;
            var defaultBillingAddress = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, defaultBillingAddressQuery).SingleOrDefault();

            var office = new ORM_CMN_STR_Office();
            office.Load(Connection, Transaction, Parameter.OfficeID);

            office.Default_BillingAddress_RefID  = (defaultBillingAddress != null) ? defaultBillingAddress.CMN_Address_RefID : Guid.Empty;
            office.Default_ShippingAddress_RefID = (defaultShippingAddress != null) ? defaultShippingAddress.CMN_Address_RefID : Guid.Empty;
            office.Save(Connection, Transaction);

            #endregion

            return(returnValue);

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

            foreach (var OrgUnitID in Parameter.OrgUnitID)
            {
                //delete  office
                var officeQuery = new ORM_CMN_STR_Office.Query();
                officeQuery.Tenant_RefID     = securityTicket.TenantID;
                officeQuery.IsDeleted        = false;
                officeQuery.CMN_STR_OfficeID = OrgUnitID;

                var office = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery).Single();
                //delete Medical practice type
                ORM_HEC_MedicalPractice_2_PracticeType.Query.SoftDelete(Connection, Transaction, new ORM_HEC_MedicalPractice_2_PracticeType.Query
                {
                    Tenant_RefID = securityTicket.TenantID,
                    IsDeleted    = false,
                    HEC_MedicalPractice_RefID = office.IfMedicalPractise_HEC_MedicalPractice_RefID
                });
                office.IsDeleted = true;
                office.Save(Connection, Transaction);

                //delete Addresses

                var addressQuery = new ORM_CMN_STR_Office_Address.Query();
                addressQuery.IsDeleted    = false;
                addressQuery.Tenant_RefID = securityTicket.TenantID;
                addressQuery.Office_RefID = OrgUnitID;

                var addressList = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, addressQuery).ToList();

                foreach (var address in addressList)
                {
                    address.IsDeleted = true;
                    address.Save(Connection, Transaction);

                    var addressDataQuery = new ORM_CMN_Address.Query();
                    addressDataQuery.IsDeleted     = false;
                    addressDataQuery.CMN_AddressID = address.CMN_Address_RefID;

                    var addressData = ORM_CMN_Address.Query.Search(Connection, Transaction, addressDataQuery).Single();
                    addressData.IsDeleted = true;
                    addressData.Save(Connection, Transaction);
                }

                //delete Unit Speciality

                //var office_2_officeTypeQuery = new ORM_CMN_STR_Office_2_OfficeType.Query();
                //office_2_officeTypeQuery.IsDeleted = false;
                //office_2_officeTypeQuery.Office_RefID = OrgUnitID;

                //var office_2_officeType = ORM_CMN_STR_Office_2_OfficeType.Query.Search(Connection, Transaction, office_2_officeTypeQuery).First();
                //office_2_officeType.IsDeleted = true;
                //office_2_officeType.Save(Connection, Transaction);

                //delete contact person data
                var responsiblePersonQuery = new ORM_CMN_STR_Office_ResponsiblePerson.Query();
                responsiblePersonQuery.Office_RefID = OrgUnitID;
                responsiblePersonQuery.IsDeleted    = false;

                var responsiblePerson = ORM_CMN_STR_Office_ResponsiblePerson.Query.Search(Connection, Transaction, responsiblePersonQuery).First();
                responsiblePerson.IsDeleted = true;
                responsiblePerson.Save(Connection, Transaction);

                var employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query();
                employeeQuery.IsDeleted = false;
                employeeQuery.CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID;

                var employee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery).Single();
                employee.IsDeleted = true;
                employee.Save(Connection, Transaction);

                var businessParticpantQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
                businessParticpantQuery.CMN_BPT_BusinessParticipantID = employee.BusinessParticipant_RefID;
                businessParticpantQuery.IsDeleted = false;

                var businessParticpant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticpantQuery).Single();
                businessParticpant.IsDeleted = true;
                businessParticpant.Save(Connection, Transaction);

                var personInfoQuery = new ORM_CMN_PER_PersonInfo.Query();
                personInfoQuery.CMN_PER_PersonInfoID = businessParticpant.IfNaturalPerson_CMN_PER_PersonInfo_RefID;
                personInfoQuery.IsDeleted            = false;

                var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery).Single();
                personInfo.IsDeleted = true;
                personInfo.Save(Connection, Transaction);

                //delete all children
                var officeQueryChildren = new ORM_CMN_STR_Office.Query();
                officeQueryChildren.Tenant_RefID = securityTicket.TenantID;
                officeQueryChildren.IsDeleted    = false;
                officeQueryChildren.Parent_RefID = OrgUnitID;

                //delete connection to appointmetn types

                var orgUnitToAppointmentTypeQuery = new ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability.Query();
                orgUnitToAppointmentTypeQuery.CMN_STR_Office_RefID = OrgUnitID;
                orgUnitToAppointmentTypeQuery.Tenant_RefID         = securityTicket.TenantID;
                orgUnitToAppointmentTypeQuery.IsDeleted            = false;

                var orgUnitToAppointmentTypeList = ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability.Query.Search(Connection, Transaction, orgUnitToAppointmentTypeQuery).ToList();

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

                var officeChildrenList = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQueryChildren).ToList();

                if (officeChildrenList.Count > 0)
                {
                    List <Guid> guidList = new List <Guid>();
                    foreach (var officeChildren in officeChildrenList)
                    {
                        guidList.Add(officeChildren.CMN_STR_OfficeID);
                    }
                    cls_Delete_OrgsUnitsGeneralData.Invoke(Connection, Transaction, new P_L5OU_DOUGD_1221 {
                        OrgUnitID = guidList.ToArray()
                    }, securityTicket);
                }
            }
            return(returnValue);

            #endregion UserCode
        }