Ejemplo n.º 1
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L5AR_DO_153 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Base();

            ORM_CMN_BPT_STA_AbsenceReason whereInstance = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_BPT_STA_AbsenceReason>();
            whereInstance.CMN_BPT_STA_AbsenceReasonID = Parameter.CMN_BPT_STA_AbsenceReasonID;
            int result = CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstance);

            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5AR_SO_154 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            var item = new ORM_CMN_BPT_STA_AbsenceReason();
            if (Parameter.CMN_BPT_STA_AbsenceReasonID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_BPT_STA_AbsenceReasonID);
                if (result.Status != FR_Status.Success || item.CMN_BPT_STA_AbsenceReasonID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }

            item.ColorCode = Parameter.ColorCode;
            //item.Description = Parameter.Description_DictID;
            item.IsAuthorizationRequired         = Parameter.IsAuthorization;
            item.IsIncludedInCapacityCalculation = Parameter.IsIncludedInCapacityCalculation;
            item.IsAllowedAbsence   = Parameter.IsAllowedAbsence;
            item.Tenant_RefID       = securityTicket.TenantID;
            item.Name               = Parameter.Name_DictID;
            item.Parent_RefID       = Parameter.Parent_RefID;
            item.ShortName          = Parameter.ShortName;
            item.IsCarryOverEnabled = Parameter.IsCarryOverEnabled;
            item.IsDeactivated      = Parameter.IsDeactivated;
            item.IsCaryOverLimited  = Parameter.IsCaryOverLimited;
            item.IfCarryOverLimited_MaximumAmount_Hrs = Parameter.IfCarryOverLimited_MaximumAmount_Hrs;
            item.IsLeaveTimeReducing_OverDays         = Parameter.IsLeaveTimeReducingOvertime;
            item.IsLeaveTimeReducing_OverHours        = Parameter.IsLeaveTimeReducingOvertime;
            item.IsLeaveTimeReducing_WorkingHours     = Parameter.IsLeaveTimeReducingWorkingHours;
            item.Save(Connection, Transaction);

            return(new FR_Guid(item.CMN_BPT_STA_AbsenceReasonID));

            #endregion UserCode
        }
        protected static FR_L5EM_GEFT_0959_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5EM_GEFT_0959_Array();
            List <L5EM_GEFT_0959>          employeeResultList = new List <L5EM_GEFT_0959>();
            ORM_CMN_BPT_EMP_Employee.Query employeeQuery      = new ORM_CMN_BPT_EMP_Employee.Query();
            employeeQuery.IsDeleted    = false;
            employeeQuery.Tenant_RefID = securityTicket.TenantID;
            List <ORM_CMN_BPT_EMP_Employee> employeeList = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery);

            foreach (var employeeItem in employeeList)
            {
                L5EM_GEFT_0959           result   = new L5EM_GEFT_0959();
                ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee();
                employee.Load(Connection, Transaction, employeeItem.CMN_BPT_EMP_EmployeeID);
                result.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID;
                result.Staff_Number           = employee.Staff_Number;
                result.StandardFunction       = employee.StandardFunction;

                ORM_USR_Account.Query accountQuery = new ORM_USR_Account.Query();
                accountQuery.BusinessParticipant_RefID = employee.BusinessParticipant_RefID;
                accountQuery.Tenant_RefID = securityTicket.TenantID;
                accountQuery.IsDeleted    = false;
                ORM_USR_Account account = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery).FirstOrDefault();
                if (account != null)
                {
                    result.USR_AccountID = account.USR_AccountID;
                }

                ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant();
                businessParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID);

                result.CMN_BPT_BusinessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID;
                result.DisplayName = businessParticipant.DisplayName;

                ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo();
                personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID);
                result.CMN_PER_PersonInfoID = personInfo.CMN_PER_PersonInfoID;
                result.FirstName            = personInfo.FirstName;
                result.LastName             = personInfo.LastName;
                result.PrimaryEmail         = personInfo.PrimaryEmail;
                result.Title = personInfo.Title;
                result.ProfileImage_Document_RefID = personInfo.ProfileImage_Document_RefID;
                result.BirthDate = personInfo.BirthDate;

                ORM_CMN_BPT_EMP_EmploymentRelationship.Query workingContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship.Query();
                workingContractQuery.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID;
                workingContractQuery.IsDeleted      = false;
                workingContractQuery.Tenant_RefID   = securityTicket.TenantID;
                ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = ORM_CMN_BPT_EMP_EmploymentRelationship.Query.Search(Connection, Transaction, workingContractQuery).FirstOrDefault();

                result.CMN_BPT_EMP_EmploymentRelationshipID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID;
                result.Work_StartDate = employmentRelationship.Work_StartDate;
                result.Work_EndDate   = employmentRelationship.Work_EndDate;

                //Address
                if (personInfo.Address_RefID != Guid.Empty)
                {
                    ORM_CMN_Address address = new ORM_CMN_Address();
                    address.Load(Connection, Transaction, personInfo.Address_RefID);
                    result.CMN_AddressID = address.CMN_AddressID;
                    result.Street_Name   = address.Street_Name;
                    result.Street_Number = address.Street_Number;
                    result.City_AdministrativeDistrict = address.City_AdministrativeDistrict;
                    result.City_Region     = address.City_Region;
                    result.City_Name       = address.City_Name;
                    result.City_PostalCode = address.City_PostalCode;
                    result.Province_Name   = address.Province_Name;
                    result.Country_Name    = address.Country_Name;
                    result.Country_ISOCode = address.Country_ISOCode;
                }

                //Contacts
                ORM_CMN_PER_CommunicationContact.Query comunicationContactQuery = new ORM_CMN_PER_CommunicationContact.Query();
                comunicationContactQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID;
                comunicationContactQuery.Tenant_RefID     = securityTicket.TenantID;
                comunicationContactQuery.IsDeleted        = false;
                List <ORM_CMN_PER_CommunicationContact> comunicationContacts       = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, comunicationContactQuery);
                List <L5EM_GEFT_0959_Contacts>          resultComunicationContacts = new List <L5EM_GEFT_0959_Contacts>();
                foreach (var comunicationContact in comunicationContacts)
                {
                    ORM_CMN_PER_CommunicationContact_Type contactType = new ORM_CMN_PER_CommunicationContact_Type();
                    contactType.Load(Connection, Transaction, comunicationContact.CMN_PER_CommunicationContactID);
                    L5EM_GEFT_0959_Contacts resultComunicationContact = new L5EM_GEFT_0959_Contacts();
                    resultComunicationContact.CMN_PER_CommunicationContact_TypeID = contactType.CMN_PER_CommunicationContact_TypeID;
                    resultComunicationContact.CMN_PER_CommunicationContactID      = comunicationContact.CMN_PER_CommunicationContactID;
                    resultComunicationContact.Content = comunicationContact.Content;
                    resultComunicationContact.Type    = contactType.Type;
                    resultComunicationContacts.Add(resultComunicationContact);
                }
                result.Contacts = resultComunicationContacts.ToArray();


                //Employee workplace history
                ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query();
                employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID;
                employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID;
                employeeWorkplaceAssignmentsQuery.IsDeleted    = false;
                List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery);
                List <L5EM_GEFT_0959_EmployeeWorkplaceHistory>      employeeWorkplaceAssignments     = new List <L5EM_GEFT_0959_EmployeeWorkplaceHistory>();

                foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList)
                {
                    L5EM_GEFT_0959_EmployeeWorkplaceHistory item = new L5EM_GEFT_0959_EmployeeWorkplaceHistory();
                    item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID;
                    item.CMN_BPT_EMP_Employee_PlanGroup_RefID       = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID;
                    item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment;
                    item.Default_BreakTime_Template_RefID           = workplaceAssignemns.Default_BreakTime_Template_RefID;
                    item.IsBreakTimeCalculated_Actual   = workplaceAssignemns.IsBreakTimeCalculated_Actual;
                    item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning;
                    item.SequenceNumber = workplaceAssignemns.SequenceNumber;
                    item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate;

                    employeeWorkplaceAssignments.Add(item);
                }

                result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray();


                //Contracts

                ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query contractTermQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query();
                contractTermQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID;
                contractTermQuery.IsDeleted    = false;
                contractTermQuery.Tenant_RefID = securityTicket.TenantID;
                List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> contracts = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, contractTermQuery);
                List <L5EM_GEFT_0959_WorkingContracts> resultContracts = new List <L5EM_GEFT_0959_WorkingContracts>();
                foreach (var contractToRelationship in contracts)
                {
                    L5EM_GEFT_0959_WorkingContracts resultContract = new L5EM_GEFT_0959_WorkingContracts();

                    ORM_CMN_BPT_EMP_WorkingContract workingContract = new ORM_CMN_BPT_EMP_WorkingContract();
                    workingContract.Load(Connection, Transaction, contractToRelationship.WorkingContract_RefID);
                    if (!workingContract.IsDeleted)
                    {
                        resultContract.CMN_BPT_EMP_WorkingContractID = workingContract.CMN_BPT_EMP_WorkingContractID;
                        resultContract.EmploymentRelationshipToWorkingContractAssignmentID = contractToRelationship.AssignmentID;
                        resultContract.IsWorkingContract_Active     = contractToRelationship.IsContract_Active;
                        resultContract.Contract_StartDate           = workingContract.Contract_StartDate;
                        resultContract.Contract_EndDate             = workingContract.Contract_EndDate;
                        resultContract.IsContractEndDateDefined     = workingContract.IsContractEndDateDefined;
                        resultContract.IsWorkTimeCalculated_InDays  = workingContract.IsWorkTimeCalculated_InDays;
                        resultContract.IsWorkTimeCalculated_InHours = workingContract.IsWorkTimeCalculated_InHours;
                        resultContract.R_WorkTime_DaysPerWeek       = workingContract.R_WorkTime_DaysPerWeek;
                        resultContract.R_WorkTime_HoursPerWeek      = workingContract.R_WorkTime_HoursPerWeek;

                        //Office hours
                        ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query workingContractTermToWorkingDayQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query();
                        workingContractTermToWorkingDayQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContract.CMN_BPT_EMP_WorkingContractID;
                        workingContractTermToWorkingDayQuery.Tenant_RefID = securityTicket.TenantID;
                        workingContractTermToWorkingDayQuery.IsDeleted    = false;
                        List <ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay> workingDayAssigments    = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, workingContractTermToWorkingDayQuery);
                        List <L5EM_GEFT_0959_WeeklyOfficeHours>             resultWeeklyOfficeHours = new List <L5EM_GEFT_0959_WeeklyOfficeHours>();
                        foreach (var workingDayAssigment in workingDayAssigments)
                        {
                            ORM_CMN_CAL_WeeklyOfficeHours_Interval interval = new ORM_CMN_CAL_WeeklyOfficeHours_Interval();
                            interval.Load(Connection, Transaction, workingDayAssigment.CMN_CAL_WeeklyOfficeHours_Interval_RefID);

                            L5EM_GEFT_0959_WeeklyOfficeHours resultOfficeHour = new L5EM_GEFT_0959_WeeklyOfficeHours();
                            resultOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = interval.CMN_CAL_WeeklyOfficeHours_IntervalID;
                            resultOfficeHour.IsFriday           = interval.IsFriday;
                            resultOfficeHour.IsMonday           = interval.IsMonday;
                            resultOfficeHour.IsSaturday         = interval.IsSaturday;
                            resultOfficeHour.IsSunday           = interval.IsSunday;
                            resultOfficeHour.IsThursday         = interval.IsThursday;
                            resultOfficeHour.IsTuesday          = interval.IsTuesday;
                            resultOfficeHour.IsWednesday        = interval.IsWednesday;
                            resultOfficeHour.IsWholeDay         = interval.IsWholeDay;
                            resultOfficeHour.TimeFrom_InMinutes = interval.TimeFrom_InMinutes;
                            resultOfficeHour.TimeTo_InMinutes   = interval.TimeTo_InMinutes;
                            resultWeeklyOfficeHours.Add(resultOfficeHour);
                        }
                        resultContract.WeeklyOfficeHours = resultWeeklyOfficeHours.ToArray();


                        //Allowed absence reasons
                        ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query AllowedAbsenceReasonQuery = new ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query();
                        AllowedAbsenceReasonQuery.WorkingContract_RefID = resultContract.CMN_BPT_EMP_WorkingContractID;
                        AllowedAbsenceReasonQuery.Tenant_RefID          = securityTicket.TenantID;
                        AllowedAbsenceReasonQuery.IsDeleted             = false;
                        List <ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason> allowedAbsenceReasons       = ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query.Search(Connection, Transaction, AllowedAbsenceReasonQuery);
                        List <L5EM_GEFT_0959_WorkingContractToLeaveRequest>         resultAllowedAbsenceReasons = new List <L5EM_GEFT_0959_WorkingContractToLeaveRequest>();
                        foreach (var allowedAbsenceReason in allowedAbsenceReasons)
                        {
                            ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason();
                            absenceReason.Load(Connection, Transaction, allowedAbsenceReason.STA_AbsenceReason_RefID);

                            L5EM_GEFT_0959_WorkingContractToLeaveRequest resultReasonresultReason = new L5EM_GEFT_0959_WorkingContractToLeaveRequest();
                            resultReasonresultReason.CMN_BPT_EMP_Employee_WorkingContract_AllowedAbsenceReasonID = allowedAbsenceReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID;
                            resultReasonresultReason.STA_AbsenceReason_RefID          = absenceReason.CMN_BPT_STA_AbsenceReasonID;
                            resultReasonresultReason.IsAbsenceCalculated_InDays       = allowedAbsenceReason.IsAbsenceCalculated_InDays;
                            resultReasonresultReason.IsAbsenceCalculated_InHours      = allowedAbsenceReason.IsAbsenceCalculated_InHours;
                            resultReasonresultReason.ContractAllowedAbsence_per_Month = allowedAbsenceReason.ContractAllowedAbsence_per_Month;
                            resultAllowedAbsenceReasons.Add(resultReasonresultReason);
                        }
                        resultContract.WorkingContractToLeaveRequest = resultAllowedAbsenceReasons.ToArray();

                        resultContracts.Add(resultContract);
                    }
                }
                result.WorkingContracts = resultContracts.ToArray();
                employeeResultList.Add(result);
            }
            returnValue.Result = employeeResultList.ToArray();
            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 4
0
        protected static FR_L5EM_GEWPGFSD_1437_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEWPGFSD_1437 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5EM_GEWPGFSD_1437_Array();
            //Put your code here

            ORM_CMN_BPT_EMP_Employee.Query empQuery = new ORM_CMN_BPT_EMP_Employee.Query();
            empQuery.IsDeleted    = false;
            empQuery.Tenant_RefID = securityTicket.TenantID;

            var allEmployees = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, empQuery);

            List <L5EM_GEWPGFSD_1437> resultList = new List <L5EM_GEWPGFSD_1437>();

            foreach (var employee in allEmployees)
            {
                L5EM_GEWPGFSD_1437 resultItem = new L5EM_GEWPGFSD_1437();
                resultItem.EmployeeID = employee.CMN_BPT_EMP_EmployeeID;

                ORM_CMN_BPT_BusinessParticipant.Query bptQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
                bptQuery.CMN_BPT_BusinessParticipantID = employee.BusinessParticipant_RefID;
                bptQuery.IsDeleted    = false;
                bptQuery.Tenant_RefID = securityTicket.TenantID;

                var bpt = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bptQuery).FirstOrDefault();

                ORM_CMN_PER_PersonInfo.Query infoQuery = new ORM_CMN_PER_PersonInfo.Query();
                infoQuery.CMN_PER_PersonInfoID = bpt.IfNaturalPerson_CMN_PER_PersonInfo_RefID;
                infoQuery.IsDeleted            = false;
                infoQuery.Tenant_RefID         = securityTicket.TenantID;

                var info = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, infoQuery).FirstOrDefault();

                int age = Parameter.SelectedDate.Year - info.BirthDate.Year;
                if (Parameter.SelectedDate < info.BirthDate.AddYears(age))
                {
                    age--;
                }

                resultItem.Age       = age;
                resultItem.FirstName = info.FirstName;
                resultItem.LastName  = info.LastName;


                ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query wpaQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query();
                wpaQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID;
                wpaQuery.IsDeleted    = false;
                wpaQuery.Tenant_RefID = securityTicket.TenantID;

                var allWorkPlaceAssignements = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, wpaQuery);

                var workPlaceAssignementsForSelectedDate = allWorkPlaceAssignements.Where(x => x.WorkplaceAssignment_StartDate.Date.CompareTo(Parameter.SelectedDate) <= 0).ToArray();
                if (workPlaceAssignementsForSelectedDate.Count() != 0)
                {
                    var resultingWorkPlaceAssignement = workPlaceAssignementsForSelectedDate.OrderByDescending(x => x.WorkplaceAssignment_StartDate.Ticks).FirstOrDefault();

                    if (resultingWorkPlaceAssignement.CMN_BPT_EMP_Employee_PlanGroup_RefID == Guid.Empty)
                    {
                        resultItem.PlanGroupID   = Guid.Empty;
                        resultItem.PlanGroupName = new Dict();
                        resultItem.Position      = -1;
                    }
                    else
                    {
                        ORM_CMN_BPT_EMP_Employee_PlanGroup.Query pgQuery = new ORM_CMN_BPT_EMP_Employee_PlanGroup.Query();
                        pgQuery.CMN_BPT_EMP_Employee_PlanGroupID = resultingWorkPlaceAssignement.CMN_BPT_EMP_Employee_PlanGroup_RefID;
                        pgQuery.IsDeleted    = false;
                        pgQuery.Tenant_RefID = securityTicket.TenantID;

                        var selectedPlanGroup = ORM_CMN_BPT_EMP_Employee_PlanGroup.Query.Search(Connection, Transaction, pgQuery).FirstOrDefault();

                        if (selectedPlanGroup == null)
                        {
                            resultItem.PlanGroupID   = Guid.Empty;
                            resultItem.PlanGroupName = new Dict();
                            resultItem.Position      = -1;
                        }
                        else
                        {
                            resultItem.PlanGroupID   = selectedPlanGroup.CMN_BPT_EMP_Employee_PlanGroupID;
                            resultItem.PlanGroupName = selectedPlanGroup.PlanGroup_Name;
                            resultItem.Position      = resultingWorkPlaceAssignement.SequenceNumber;
                        }

                        resultItem.IsBreakTimeCalculated_Planning = resultingWorkPlaceAssignement.IsBreakTimeCalculated_Planning;
                        resultItem.IsBreakTimeCalculated_Actual   = resultingWorkPlaceAssignement.IsBreakTimeCalculated_Actual;
                    }
                }
                else
                {
                    continue;
                }

                ORM_CMN_BPT_EMP_EmploymentRelationship.Query employmentRelationshipQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship.Query();
                employmentRelationshipQuery.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID;
                employmentRelationshipQuery.Tenant_RefID   = securityTicket.TenantID;
                employmentRelationshipQuery.IsDeleted      = false;

                ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = ORM_CMN_BPT_EMP_EmploymentRelationship.Query.Search(Connection, Transaction, employmentRelationshipQuery).FirstOrDefault();

                ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query er2wcQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query();
                er2wcQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID;
                er2wcQuery.Tenant_RefID      = securityTicket.TenantID;
                er2wcQuery.IsContract_Active = true;
                er2wcQuery.IsDeleted         = false;



                ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract er2wc = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, er2wcQuery).FirstOrDefault();
                if (er2wc != null)
                {
                    ORM_CMN_BPT_EMP_WorkingContract.Query workingContractQuery = new ORM_CMN_BPT_EMP_WorkingContract.Query();
                    workingContractQuery.CMN_BPT_EMP_WorkingContractID = er2wc.WorkingContract_RefID;
                    workingContractQuery.IsDeleted    = false;
                    workingContractQuery.Tenant_RefID = securityTicket.TenantID;

                    ORM_CMN_BPT_EMP_WorkingContract workingContract = ORM_CMN_BPT_EMP_WorkingContract.Query.Search(Connection, Transaction, workingContractQuery).FirstOrDefault();

                    resultItem.IsWorkTimeCalculated_InDays  = workingContract.IsWorkTimeCalculated_InDays;
                    resultItem.IsWorkTimeCalculated_InHours = workingContract.IsWorkTimeCalculated_InHours;

                    ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query wc2wdQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query();
                    wc2wdQuery.CMN_BPT_EMP_WorkingContract_RefID = er2wc.WorkingContract_RefID;
                    wc2wdQuery.Tenant_RefID = securityTicket.TenantID;
                    wc2wdQuery.IsDeleted    = false;

                    ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay[] workingContract2workingDays = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, wc2wdQuery).ToArray();

                    resultItem.ContractSpecifiedWorkTime_InMinutes = 0;
                    List <WeeklyOfficeHours> listOfWeeklyOfficeHours = new List <WeeklyOfficeHours>();

                    foreach (var workingContract2workingDay in workingContract2workingDays)
                    {
                        ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query weeklyOfficeHoursQuery = new ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query();
                        weeklyOfficeHoursQuery.CMN_CAL_WeeklyOfficeHours_IntervalID = workingContract2workingDay.CMN_CAL_WeeklyOfficeHours_Interval_RefID;
                        weeklyOfficeHoursQuery.Tenant_RefID = securityTicket.TenantID;
                        weeklyOfficeHoursQuery.IsDeleted    = false;

                        ORM_CMN_CAL_WeeklyOfficeHours_Interval weeklyOfficeHours = ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query.Search(Connection, Transaction, weeklyOfficeHoursQuery).FirstOrDefault();

                        switch (Parameter.SelectedDate.DayOfWeek)
                        {
                        case DayOfWeek.Monday:
                            if (weeklyOfficeHours.IsMonday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;

                        case DayOfWeek.Tuesday:
                            if (weeklyOfficeHours.IsTuesday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;

                        case DayOfWeek.Wednesday:
                            if (weeklyOfficeHours.IsWednesday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;

                        case DayOfWeek.Thursday:
                            if (weeklyOfficeHours.IsThursday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;

                        case DayOfWeek.Friday:
                            if (weeklyOfficeHours.IsFriday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;

                        case DayOfWeek.Saturday:
                            if (weeklyOfficeHours.IsSaturday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;

                        case DayOfWeek.Sunday:
                            if (weeklyOfficeHours.IsSunday)
                            {
                                resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes);
                            }
                            break;
                        }

                        WeeklyOfficeHours newWeeklyOfficeHour = new WeeklyOfficeHours();
                        newWeeklyOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = weeklyOfficeHours.CMN_CAL_WeeklyOfficeHours_IntervalID;
                        newWeeklyOfficeHour.IsFriday           = weeklyOfficeHours.IsFriday;
                        newWeeklyOfficeHour.IsMonday           = weeklyOfficeHours.IsMonday;
                        newWeeklyOfficeHour.IsSaturday         = weeklyOfficeHours.IsSaturday;
                        newWeeklyOfficeHour.IsSunday           = weeklyOfficeHours.IsSunday;
                        newWeeklyOfficeHour.IsThursday         = weeklyOfficeHours.IsThursday;
                        newWeeklyOfficeHour.IsTuesday          = weeklyOfficeHours.IsTuesday;
                        newWeeklyOfficeHour.IsWednesday        = weeklyOfficeHours.IsWednesday;
                        newWeeklyOfficeHour.IsWholeDay         = weeklyOfficeHours.IsWholeDay;
                        newWeeklyOfficeHour.TimeFrom_InMinutes = weeklyOfficeHours.TimeFrom_InMinutes;
                        newWeeklyOfficeHour.TimeTo_InMinutes   = weeklyOfficeHours.TimeTo_InMinutes;

                        listOfWeeklyOfficeHours.Add(newWeeklyOfficeHour);
                    }


                    resultItem.WeeklyOfficeHours = listOfWeeklyOfficeHours.ToArray();
                }
                else
                {
                    continue;
                }

                ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query relationShipToContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query();
                relationShipToContractQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID;
                relationShipToContractQuery.IsDeleted    = false;
                relationShipToContractQuery.Tenant_RefID = securityTicket.TenantID;
                List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> relationShipToContracts = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, relationShipToContractQuery);
                List <L5EM_GEFE_1150_WorkingContract> resultWorkingContracts = new List <L5EM_GEFE_1150_WorkingContract>();
                foreach (var relationShipToContract in relationShipToContracts)
                {
                    L5EM_GEFE_1150_WorkingContract resultWorkingContract = new L5EM_GEFE_1150_WorkingContract();

                    ORM_CMN_BPT_EMP_WorkingContract workingContractItem = new ORM_CMN_BPT_EMP_WorkingContract();
                    workingContractItem.Load(Connection, Transaction, relationShipToContract.WorkingContract_RefID);
                    resultWorkingContract.CMN_BPT_EMP_WorkingContractID = workingContractItem.CMN_BPT_EMP_WorkingContractID;
                    resultWorkingContract.EmploymentRelationship_2_WorkingContractAssigmentID = relationShipToContract.AssignmentID;
                    resultWorkingContract.IsContract_Active                   = relationShipToContract.IsContract_Active;
                    resultWorkingContract.Contract_StartDate                  = workingContractItem.Contract_StartDate;
                    resultWorkingContract.Contract_EndDate                    = workingContractItem.Contract_EndDate;
                    resultWorkingContract.IsContractEndDateDefined            = workingContractItem.IsContractEndDateDefined;
                    resultWorkingContract.IsWorkTimeCalculated_InDays         = workingContractItem.IsWorkTimeCalculated_InDays;
                    resultWorkingContract.IsWorkTimeCalculated_InHours        = workingContractItem.IsWorkTimeCalculated_InHours;
                    resultWorkingContract.R_WorkTime_DaysPerWeek              = workingContractItem.R_WorkTime_DaysPerWeek;
                    resultWorkingContract.R_WorkTime_HoursPerWeek             = workingContractItem.R_WorkTime_HoursPerWeek;
                    resultWorkingContract.WorkingContract_InCurrency_RefID    = workingContractItem.WorkingContract_InCurrency_RefID;
                    resultWorkingContract.ExtraWorkCalculation_RefID          = workingContractItem.ExtraWorkCalculation_RefID;
                    resultWorkingContract.IsWorktimeChecked_Weekly            = workingContractItem.IsWorktimeChecked_Weekly;
                    resultWorkingContract.IsWorktimeChecked_Monthly           = workingContractItem.IsWorktimeChecked_Monthly;
                    resultWorkingContract.SurchargeCalculation_UseMaximum     = workingContractItem.SurchargeCalculation_UseMaximum;
                    resultWorkingContract.SurchargeCalculation_UseAccumulated = workingContractItem.SurchargeCalculation_UseAccumulated;
                    resultWorkingContract.IsMealAllowanceProvided             = workingContractItem.IsMealAllowanceProvided;
                    resultWorkingContract.WorkingContract_Comment             = workingContractItem.WorkingContract_Comment;

                    ORM_CMN_BPT_EMP_WorkingContract_2_ExtraWorkSurcharge.Query contractToExtraWorkSurchargeQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_ExtraWorkSurcharge.Query();
                    contractToExtraWorkSurchargeQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContractItem.CMN_BPT_EMP_WorkingContractID;
                    contractToExtraWorkSurchargeQuery.IsDeleted    = false;
                    contractToExtraWorkSurchargeQuery.Tenant_RefID = securityTicket.TenantID;
                    var contractToExtraWorkSurchargeResult = ORM_CMN_BPT_EMP_WorkingContract_2_ExtraWorkSurcharge.Query.Search(Connection, Transaction, contractToExtraWorkSurchargeQuery);
                    if (contractToExtraWorkSurchargeResult.Count != 0)
                    {
                        var nightTimeSurcharge    = contractToExtraWorkSurchargeResult.FirstOrDefault(x => x.R_IsNightTimeSurcharge && !x.R_IsSpecialEventSurcharge);
                        var specialEventSurcharge = contractToExtraWorkSurchargeResult.FirstOrDefault(x => x.R_IsSpecialEventSurcharge && !x.R_IsNightTimeSurcharge);

                        if (nightTimeSurcharge != null)
                        {
                            resultWorkingContract.NightTime_Surcharge_RefID = nightTimeSurcharge.CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_RefID;
                            resultWorkingContract.MaximumAllowedNightTimeSurchargeTime_in_mins = nightTimeSurcharge.MaximumAllowedSurchargeTime_in_mins;
                        }

                        if (specialEventSurcharge != null)
                        {
                            resultWorkingContract.SpecialEvent_Surcharge_RefID = specialEventSurcharge.CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_RefID;
                            resultWorkingContract.MaximumAllowedSpecialEventSurchargeTime_in_mins = specialEventSurcharge.MaximumAllowedSurchargeTime_in_mins;
                        }
                    }


                    //Office hours
                    ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query workingContractToWorkingDayQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query();
                    workingContractToWorkingDayQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContractItem.CMN_BPT_EMP_WorkingContractID;
                    //workingContractToWorkingDayQuery.Tenant_RefID = securityTicket.TenantID;
                    workingContractToWorkingDayQuery.IsDeleted = false;
                    List <ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay> workingDayAssigments    = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, workingContractToWorkingDayQuery);
                    List <L5EM_GEFE_1150_WeeklyOfficeHours>             resultWeeklyOfficeHours = new List <L5EM_GEFE_1150_WeeklyOfficeHours>();
                    foreach (var workingDayAssigment in workingDayAssigments)
                    {
                        ORM_CMN_CAL_WeeklyOfficeHours_Interval interval = new ORM_CMN_CAL_WeeklyOfficeHours_Interval();
                        interval.Load(Connection, Transaction, workingDayAssigment.CMN_CAL_WeeklyOfficeHours_Interval_RefID);

                        L5EM_GEFE_1150_WeeklyOfficeHours resultOfficeHour = new L5EM_GEFE_1150_WeeklyOfficeHours();
                        resultOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = interval.CMN_CAL_WeeklyOfficeHours_IntervalID;
                        resultOfficeHour.IsFriday           = interval.IsFriday;
                        resultOfficeHour.IsMonday           = interval.IsMonday;
                        resultOfficeHour.IsSaturday         = interval.IsSaturday;
                        resultOfficeHour.IsSunday           = interval.IsSunday;
                        resultOfficeHour.IsThursday         = interval.IsThursday;
                        resultOfficeHour.IsTuesday          = interval.IsTuesday;
                        resultOfficeHour.IsWednesday        = interval.IsWednesday;
                        resultOfficeHour.IsWholeDay         = interval.IsWholeDay;
                        resultOfficeHour.TimeFrom_InMinutes = interval.TimeFrom_InMinutes;
                        resultOfficeHour.TimeTo_InMinutes   = interval.TimeTo_InMinutes;
                        resultWeeklyOfficeHours.Add(resultOfficeHour);
                    }
                    resultWorkingContract.WeeklyOfficeHours = resultWeeklyOfficeHours.ToArray();



                    ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType.Query workingContractTypeQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType.Query();
                    workingContractTypeQuery.CMN_BPT_EMP_Employee_WorkingContract_RefID = workingContractItem.CMN_BPT_EMP_WorkingContractID;
                    workingContractTypeQuery.Tenant_RefID = securityTicket.TenantID;
                    workingContractTypeQuery.IsDeleted    = false;
                    ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType workingContract_2_ContractEmploymentType = ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType.Query.Search(Connection, Transaction, workingContractTypeQuery).FirstOrDefault();
                    if (workingContract_2_ContractEmploymentType != null)
                    {
                        ORM_CMN_BPT_EMP_WorkingContract_EmploymentType EmploymentType = new ORM_CMN_BPT_EMP_WorkingContract_EmploymentType();
                        EmploymentType.Load(Connection, Transaction, workingContract_2_ContractEmploymentType.CMN_BPT_EMP_WorkingContract_EmploymentTypeID);
                        if (EmploymentType.CMN_BPT_EMP_Employee_WorkingContract_EmploymentTypeID != Guid.Empty)
                        {
                            resultWorkingContract.TypeOfEmployment = int.Parse(EmploymentType.GlobalPropertyMatchingID);
                        }
                    }


                    //Allowed absence reasons
                    ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query AllowedAbsenceReasonQuery = new ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query();
                    AllowedAbsenceReasonQuery.WorkingContract_RefID = resultWorkingContract.CMN_BPT_EMP_WorkingContractID;
                    AllowedAbsenceReasonQuery.Tenant_RefID          = securityTicket.TenantID;
                    AllowedAbsenceReasonQuery.IsDeleted             = false;
                    List <ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason> allowedAbsenceReasons       = ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query.Search(Connection, Transaction, AllowedAbsenceReasonQuery);
                    List <L5EM_GEFE_1150_WorkingContractToLeaveRequest>         resultAllowedAbsenceReasons = new List <L5EM_GEFE_1150_WorkingContractToLeaveRequest>();
                    foreach (var allowedAbsenceReason in allowedAbsenceReasons)
                    {
                        ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason();
                        absenceReason.Load(Connection, Transaction, allowedAbsenceReason.STA_AbsenceReason_RefID);

                        L5EM_GEFE_1150_WorkingContractToLeaveRequest resultReasonresultReason = new L5EM_GEFE_1150_WorkingContractToLeaveRequest();
                        resultReasonresultReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID = allowedAbsenceReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID;
                        resultReasonresultReason.CMN_BPT_STA_AbsenceReasonID      = absenceReason.CMN_BPT_STA_AbsenceReasonID;
                        resultReasonresultReason.IsAbsenceCalculated_InDays       = allowedAbsenceReason.IsAbsenceCalculated_InDays;
                        resultReasonresultReason.IsAbsenceCalculated_InHours      = allowedAbsenceReason.IsAbsenceCalculated_InHours;
                        resultReasonresultReason.ContractAllowedAbsence_per_Month = allowedAbsenceReason.ContractAllowedAbsence_per_Month;
                        resultReasonresultReason.AbsenceReasonName = absenceReason.Name;
                        resultReasonresultReason.CMN_BPT_EMP_EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID;
                        resultAllowedAbsenceReasons.Add(resultReasonresultReason);
                    }
                    resultWorkingContract.WorkingContractToLeaveRequest = resultAllowedAbsenceReasons.ToArray();

                    resultWorkingContracts.Add(resultWorkingContract);
                }
                resultItem.AllWorkingContracts = resultWorkingContracts.ToArray();

                //Employee workplace history
                ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query();
                employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID;
                employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID;
                employeeWorkplaceAssignmentsQuery.IsDeleted    = false;
                List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery);
                List <L5EM_GEFE_1150_EmployeeWorkplaceHistory>      employeeWorkplaceAssignments     = new List <L5EM_GEFE_1150_EmployeeWorkplaceHistory>();

                foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList)
                {
                    L5EM_GEFE_1150_EmployeeWorkplaceHistory item = new L5EM_GEFE_1150_EmployeeWorkplaceHistory();
                    item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID;
                    item.CMN_BPT_EMP_Employee_PlanGroup_RefID       = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID;
                    item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment;
                    item.Default_BreakTime_Template_RefID           = workplaceAssignemns.Default_BreakTime_Template_RefID;
                    item.IsBreakTimeCalculated_Actual   = workplaceAssignemns.IsBreakTimeCalculated_Actual;
                    item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning;
                    item.SequenceNumber = workplaceAssignemns.SequenceNumber;
                    item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate;

                    employeeWorkplaceAssignments.Add(item);
                }

                resultItem.AllWorkplaceHistories = employeeWorkplaceAssignments.ToArray();

                //employee qualifications
                ORM_CMN_BPT_EMP_Employee_2_Skill.Query qualificationQuary = new ORM_CMN_BPT_EMP_Employee_2_Skill.Query();
                qualificationQuary.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID;
                qualificationQuary.Tenant_RefID   = securityTicket.TenantID;
                qualificationQuary.IsDeleted      = false;
                List <ORM_CMN_BPT_EMP_Employee_2_Skill>     qualificationList      = ORM_CMN_BPT_EMP_Employee_2_Skill.Query.Search(Connection, Transaction, qualificationQuary);
                List <L5EM_GEFE_1150_EmployeeQualification> employeeQualifications = new List <L5EM_GEFE_1150_EmployeeQualification>();

                L5EM_GEFE_1150_EmployeeQualification employeeQualification;
                ORM_CMN_STR_Skill skillORM;
                foreach (var qualification in qualificationList)
                {
                    employeeQualification = new L5EM_GEFE_1150_EmployeeQualification();
                    employeeQualification.QualificationAssignmentID = qualification.AssignmentID;
                    employeeQualification.ProfessionObtainedAtDate  = qualification.QualificationObtainedAtDate;
                    employeeQualification.SkillName = new Dict();
                    if (qualification.Skill_RefID != Guid.Empty)
                    {
                        skillORM = new ORM_CMN_STR_Skill();
                        skillORM.Load(Connection, Transaction, qualification.Skill_RefID);
                        employeeQualification.Skill_RefID = skillORM.CMN_STR_SkillID;
                        employeeQualification.SkillName   = skillORM.Skill_Name;
                    }

                    employeeQualifications.Add(employeeQualification);
                }

                resultItem.AllQualification = employeeQualifications.ToArray();


                resultList.Add(resultItem);
            }

            returnValue.Result = resultList.ToArray();


            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 5
0
        protected static FR_L6LR_GLR_ID_1339 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LR_GLR_ID_1339 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6LR_GLR_ID_1339();
            returnValue.Result = new L6LR_GLR_ID_1339();


            //Covers
            ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query leaveRequestQuery = new ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query();
            leaveRequestQuery.CMN_BPT_EMP_Employee_LeaveRequestID = Parameter.LeaveID;
            leaveRequestQuery.Tenant_RefID = securityTicket.TenantID;
            leaveRequestQuery.IsDeleted    = false;
            ORM_CMN_BPT_EMP_Employee_LeaveRequest leaveRequest = ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query.Search(Connection, Transaction, leaveRequestQuery).FirstOrDefault();
            ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee();
            employee.Load(Connection, Transaction, leaveRequest.RequestedFor_Employee_RefID);
            L5LR_GLRFSP_1532 result = new L5LR_GLRFSP_1532();
            result.ForEmployeeID = employee.CMN_BPT_EMP_EmployeeID;
            result.ForEmployee_BusinessParticipant_RefID = employee.BusinessParticipant_RefID;
            result.ForEmployee_Staff_Number     = employee.Staff_Number;
            result.ForEmployee_StandardFunction = employee.StandardFunction;
            result.LeaveRequestCreationSource   = leaveRequest.LeaveRequestCreationSource;
            ORM_CMN_BPT_BusinessParticipant bpart = new ORM_CMN_BPT_BusinessParticipant();
            bpart.Load(Connection, Transaction, employee.BusinessParticipant_RefID);

            ORM_CMN_PER_PersonInfo per = new ORM_CMN_PER_PersonInfo();
            per.Load(Connection, Transaction, bpart.IfNaturalPerson_CMN_PER_PersonInfo_RefID);
            result.FirstName = per.FirstName;
            result.LastName  = per.LastName;

            result.CMN_CAL_Event_RefID          = leaveRequest.CMN_CAL_Event_RefID;
            result.CMN_CAL_Event_Approval_RefID = leaveRequest.CMN_CAL_Event_Approval_RefID;
            //result.AbsenceReason_Type_RefID = leaveRequest.CMN_BPT_STA_AbsenceReason_RefID;
            result.Comment = leaveRequest.Comment;
            result.RequestedBy_Employee_RefID          = leaveRequest.RequestedBy_Employee_RefID;
            result.CMN_BPT_EMP_Employee_LeaveRequestID = leaveRequest.CMN_BPT_EMP_Employee_LeaveRequestID;
            ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover.Query covers = new ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover.Query();
            covers.CMN_BPT_EMP_Employee_LeaveRequests = leaveRequest.CMN_BPT_EMP_Employee_LeaveRequestID;
            covers.Tenant_RefID = securityTicket.TenantID;
            covers.IsDeleted    = false;
            List <ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover> employeeCovers = ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover.Query.Search(Connection, Transaction, covers);
            result.Cover = new L5LR_GLRFSP_1532_Cover();
            if (employeeCovers.Count != 0)
            {
                ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover employeeCover = employeeCovers[0];
                result.Cover.CMN_BPT_EMP_EmployeeID = employeeCover.EmployeeCover_RefID;
                result.Cover.CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCoverID = employeeCover.CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCoverID;
                result.Cover.SequenceNumber = employeeCover.SequenceNumber;
            }

            ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason();
            absenceReason.Load(Connection, Transaction, leaveRequest.CMN_BPT_STA_AbsenceReason_RefID);

            result.CMN_BPT_STA_AbsenceReason_RefID = absenceReason.CMN_BPT_STA_AbsenceReasonID;
            result.ShortName  = absenceReason.ShortName;
            result.ReasonName = absenceReason.Name;
            result.ReasonDesc = absenceReason.Description;
            result.AbsenceReason_Type_RefID = absenceReason.AbsenceReason_Type_RefID;
            result.ColorCode                            = absenceReason.ColorCode;
            result.Parent_RefID                         = absenceReason.Parent_RefID;
            result.IsAuthorizationRequired              = absenceReason.IsAuthorizationRequired;
            result.IsIncludedInCapacityCalculation      = absenceReason.IsIncludedInCapacityCalculation;
            result.IsAllowedAbsence                     = absenceReason.IsAllowedAbsence;
            result.IsDeactivated                        = absenceReason.IsDeactivated;
            result.IsCarryOverEnabled                   = absenceReason.IsCarryOverEnabled;
            result.IsCaryOverLimited                    = absenceReason.IsCaryOverLimited;
            result.IfCarryOverLimited_MaximumAmount_Hrs = absenceReason.IfCarryOverLimited_MaximumAmount_Hrs;

            ORM_CMN_CAL_Event Event = new ORM_CMN_CAL_Event();
            Event.Load(Connection, Transaction, leaveRequest.CMN_CAL_Event_RefID);

            result.CalendarInstance_RefID = Event.CalendarInstance_RefID;
            result.StartTime           = Event.StartTime;
            result.EndTime             = Event.EndTime;
            result.R_EventDuration_sec = Event.R_EventDuration_sec;

            ORM_CMN_CAL_Event_Approval eventApproval = new ORM_CMN_CAL_Event_Approval();
            eventApproval.Load(Connection, Transaction, leaveRequest.CMN_CAL_Event_Approval_RefID);

            result.Action = new L5LR_GLRFSP_1532_Action();

            result.IsApproved = eventApproval.IsApproved;
            result.IsApprovalProcessOpened = eventApproval.IsApprovalProcessOpened;
            result.IsApprovalProcessDenied = eventApproval.IsApprovalProcessDenied;

            ORM_CMN_CAL_Event_Approval_Action.Query approvalQuery = new ORM_CMN_CAL_Event_Approval_Action.Query();
            approvalQuery.EventApproval_RefID = eventApproval.CMN_CAL_Event_ApprovalID;
            approvalQuery.Tenant_RefID        = securityTicket.TenantID;
            approvalQuery.IsDeleted           = false;
            List <ORM_CMN_CAL_Event_Approval_Action> apporvalActions = ORM_CMN_CAL_Event_Approval_Action.Query.Search(Connection, Transaction, approvalQuery);
            if (apporvalActions.Count != 0)
            {
                ORM_CMN_CAL_Event_Approval_Action approvalAction = apporvalActions[0];
                result.Action.ActionTriggeredBy_Account_RefID = approvalAction.ActionTriggeredBy_Account_RefID;
                result.Action.CMN_CAL_Event_Approval_ActionID = approvalAction.CMN_CAL_Event_Approval_ActionID;
                result.Action.IsApproval              = approvalAction.IsApproval;
                result.Action.IsRevocation            = approvalAction.IsRevocation;
                result.Action.IsDenial                = approvalAction.IsDenial;
                result.Action.Approval_Action_Commnet = approvalAction.Comment;
            }

            returnValue.Result.Leave = result;
            //Put your code here
            return(returnValue);

            #endregion UserCode
        }