Exemplo n.º 1
0
        /// <summary>
        /// get Actual Org and Actual Job from organization structure module if he is a manager, but if he is a normal employee, get from internal assignings module
        /// </summary>
        /// <param name="EmployeeCodeNo"></param>
        /// <returns></returns>
        public PlacementBLL GetCurrentActualOrgAndActualJob(string EmployeeCodeNo)
        {
            try
            {
                PlacementBLL CurrentOrgAndJob = null;
                OrganizationsStructuresBLL OrganizationsStructureBasedOnManagement = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(EmployeeCodeNo)?.FirstOrDefault();
                if (OrganizationsStructureBasedOnManagement != null)
                {
                    OrganizationsStructureBasedOnManagement.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(OrganizationsStructureBasedOnManagement.OrganizationID);
                    CurrentOrgAndJob = new PlacementBLL()
                    {
                        Organization = OrganizationsStructureBasedOnManagement, Job = new JobsBLL()
                        {
                            JobName = Globalization.ManagerText + " " + OrganizationsStructureBasedOnManagement.OrganizationName
                        }
                    };
                }
                else
                {
                    BaseAssigningsBLL CurrentAssigningRecord = new InternalAssigningBLL().GetEmployeeActiveAssigning(EmployeeCodeNo);
                    if (CurrentAssigningRecord != null)
                    {
                        CurrentOrgAndJob = new PlacementBLL()
                        {
                            Organization = ((InternalAssigningBLL)CurrentAssigningRecord).Organization, Job = ((InternalAssigningBLL)CurrentAssigningRecord).Job
                        }
                    }
                    ;
                }

                return(CurrentOrgAndJob);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        internal Result AddEVacationRequest()
        {
            try
            {
                Result             result;
                PlacementBLL       CurrentActualOrgAndActualJob = new PlacementBLL().GetCurrentActualOrgAndActualJob(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo);
                EVacationsRequests EVacationRequest             = new EVacationsRequests()
                {
                    EmployeeCareerHistoryID = this.EmployeeCareerHistory.EmployeeCareerHistoryID,
                    //ActualOrganizationID = CurrentActualOrgAndActualJob != null ? CurrentActualOrgAndActualJob?.Organization?.OrganizationID : (int?)null,
                    //ActualJobID = CurrentActualOrgAndActualJob != null ? CurrentActualOrgAndActualJob?.Job?.JobID != 0 ? CurrentActualOrgAndActualJob?.Job?.JobID : (int?)null : null,
                    ActualOrganizationID     = CurrentActualOrgAndActualJob?.Organization?.OrganizationID,
                    ActualJobID              = CurrentActualOrgAndActualJob?.Job?.JobID == 0 ? null : CurrentActualOrgAndActualJob?.Job?.JobID,
                    VacationStartDate        = this.VacationStartDate,
                    VacationEndDate          = this.VacationEndDate,
                    CreatorNotes             = this.CreatorNotes,
                    VacationTypeID           = (int)this.VacationTypeEnum,
                    EVacationRequestNo       = new EVacationsRequestsDAL().GetMaxEVacationRequestNoByYear(DateTime.Now.Year) + 1,
                    EVacationRequestStatusID = (int)EVacationRequestStatusEnum.Pending,
                    CreatedDate              = DateTime.Now,
                    CreatedBy = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
                };

                #region Validation to check there is any e vacation request is pending or not
                // pending means that no action by his manager till now or this e vacation is not cancelled by creator
                result = IsEVacationRequestPendingExist(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo);
                if (result != null)
                {
                    return(result);
                }
                #endregion

                #region Checking proxies
                #region Validation to check if the requester is authorized person in e services authorizations module ... if the requester has e services authorizations :
                // 1 - he can not create e vacation request if the vacation start date will be in the future
                // 2 - he can create e vacation request if the vacation period will be in the past
                if (this.VacationStartDate > DateTime.Now || this.VacationEndDate > DateTime.Now) // no need to check about of old vacations
                {
                    EServicesAuthorizationsBLL EServiceAuthorization = new EServicesAuthorizationsBLL().GetOrganizationAuthorizedPerson(CurrentActualOrgAndActualJob.Organization.OrganizationID, EServicesTypesEnum.Vacation);
                    if (EServiceAuthorization.AuthorizedPerson.EmployeeCodeNo == this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo) // thats mean the manager has authorization
                    {
                        // check the manager created valid proxy to e vacation service to other person or not
                        EServicesProxiesBLL ActiveProxy = new EServicesProxiesBLL().GetActiveByFromEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, EServicesTypesEnum.Vacation);
                        if (ActiveProxy == null) // thats mean he did not create valid proxy to e vacation service to other person
                        {
                            result = new Result();
                            //result.Entity = this;
                            result.EnumMember = VacationsValidationEnum.RejectedBecauseOfNoActiveProxyCreatedToOtherPerson.ToString();
                            return(result);
                        }
                    }

                    #region check the employee has proxy by other person or not
                    EServicesProxiesBLL ActiveEVacationServiceProxy = new EServicesProxiesBLL().GetActiveByToEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID).FirstOrDefault(x => x.EServiceType.EServiceTypeID == (int)EServicesTypesEnum.Vacation);
                    if (ActiveEVacationServiceProxy != null) // thats mean he is proxied by other person
                    {
                        result            = new Result();
                        result.Entity     = ActiveEVacationServiceProxy;
                        result.EnumMember = VacationsValidationEnum.RejectedBecauseOfEmployeeHasProxyByOtherPerson.ToString();
                        return(result);
                    }
                    #endregion
                }

                #endregion
                #endregion

                result = new Result();
                new EVacationsRequestsDAL().Insert(EVacationRequest);
                this.EVacationRequestNo = EVacationRequest.EVacationRequestNo;
                result.Entity           = this;
                result.EnumMember       = VacationsValidationEnum.Done.ToString();

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }