Example #1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5DO_SPwDC_1515 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5DO_SPwDC_1515 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5DO_SPwDC_1515 functionReturn = new FR_L5DO_SPwDC_1515();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Save_Profession_withDeleteCheck", ex);
            }
            return(functionReturn);
        }
Example #2
0
        protected static FR_L5DO_SPwDC_1515 Execute(DbConnection Connection, DbTransaction Transaction, P_L5DO_SPwDC_1515 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5DO_SPwDC_1515();
            //Put your code here

            returnValue.Result = new L5DO_SPwDC_1515();

            Guid ProfessionId = Guid.Empty;
            if (!Parameter.BaseData.IsDeleted)
            {
                ProfessionId = cls_Save_Profession.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result;
            }
            else
            {
                List <ORM_CMN_BPT_EMP_Employee_2_Profession> existingEmployee = ORM_CMN_BPT_EMP_Employee_2_Profession.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee_2_Profession.Query
                {
                    IsDeleted        = false,
                    Tenant_RefID     = securityTicket.TenantID,
                    Profession_RefID = Parameter.BaseData.StaffTypeID
                }).ToList();

                if (existingEmployee.Count > 0) //cannot delete
                {
                    List <L5DO_SPwDC_1515_UsedInEmployee> usedEmployeeList = new List <L5DO_SPwDC_1515_UsedInEmployee>();

                    foreach (var employee in existingEmployee)
                    {
                        L5DO_GSNfEID_1107 employeeName = cls_Get_Staff_Name_for_EmployeeID.Invoke(Connection, Transaction, new P_L5DO_GSNfEID_1107 {
                            EmployeeID = employee.Employee_RefID
                        }, securityTicket).Result;
                        string fullName = employeeName.FirstName + " " + employeeName.LastName;
                        usedEmployeeList.Add(new L5DO_SPwDC_1515_UsedInEmployee {
                            EmployeeName = fullName
                        });
                    }
                    returnValue.Result.UsedInEmployee = usedEmployeeList.ToArray();
                }

                List <ORM_PPS_TSK_Task_RequiredStaff_Profession> existingAppointmentType = ORM_PPS_TSK_Task_RequiredStaff_Profession.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_RequiredStaff_Profession.Query
                {
                    IsDeleted                = false,
                    Tenant_RefID             = securityTicket.TenantID,
                    CMN_STR_Profession_RefID = Parameter.BaseData.StaffTypeID
                }).ToList();

                if (existingAppointmentType.Count > 0) //cannot delete
                {
                    List <L5DO_SPwDC_1515_UsedInAppointmentType> usedAppointmentTypeList = new List <L5DO_SPwDC_1515_UsedInAppointmentType>();

                    foreach (var appointmentType in existingAppointmentType)
                    {
                        ORM_PPS_TSK_Task_RequiredStaff reqStaff = ORM_PPS_TSK_Task_RequiredStaff.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_RequiredStaff.Query
                        {
                            IsDeleted    = false,
                            Tenant_RefID = securityTicket.TenantID,
                            PPS_TSK_Task_RequiredStaffID = appointmentType.RequiredStaff_RefID
                        }).Single();
                        ORM_PPS_TSK_Task_Template appointmentTypeName = ORM_PPS_TSK_Task_Template.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_Template.Query
                        {
                            IsDeleted               = false,
                            Tenant_RefID            = securityTicket.TenantID,
                            PPS_TSK_Task_TemplateID = reqStaff.TaskTemplate_RefID
                        }).Single();
                        usedAppointmentTypeList.Add(new L5DO_SPwDC_1515_UsedInAppointmentType {
                            AppointmentTypeName = appointmentTypeName.TaskTemplateName
                        });
                    }

                    returnValue.Result.UsedInAppointmentType = usedAppointmentTypeList.ToArray();
                }

                if (existingEmployee.Count == 0 && existingAppointmentType.Count == 0)
                {
                    ProfessionId = cls_Save_Profession.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result;
                }
            }
            returnValue.Result.ID = ProfessionId;

            return(returnValue);

            #endregion UserCode
        }