Beispiel #1
0
        public List <EVacationsRequestsBLL> GetPendingEVacationsRequestsByAuthorizedPerson(string AuthorizedPersonCodeNo)
        {
            try
            {
                List <EServicesAuthorizationsBLL> OrganizationsList = new EServicesAuthorizationsBLL().GetBasedOnAuthorizedPerson(AuthorizedPersonCodeNo, EServicesTypesEnum.Vacation);
                List <int> OrganizationsIDs = new List <int>();
                OrganizationsList.ForEach(x => OrganizationsIDs.Add(x.Organization.OrganizationID));

                #region Get evacations requests of normal employees
                List <EVacationsRequests>    EVacationsRequestsList    = new EVacationsRequestsDAL().GetEVacationsRequestsByOrganizations(OrganizationsIDs).Where(x => x.EVacationRequestStatusID == (int)EVacationRequestStatusEnum.Pending).ToList();
                List <EVacationsRequestsBLL> EVacationsRequestsBLLList = new List <EVacationsRequestsBLL>();
                EVacationsRequestsList.ForEach(x => EVacationsRequestsBLLList.Add(MapEVacationRequest(x)));
                #endregion

                #region Get evacations requests of managers under him
                List <int> OrganizationIDList = new List <int>();
                new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(AuthorizedPersonCodeNo).ForEach(x => OrganizationIDList.Add(x.OrganizationID));
                //int? OrganizationID = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(AuthorizedPersonCodeNo).FirstOrDefault()?.OrganizationID;
                foreach (var OrganizationID in OrganizationIDList)
                {
                    List <int> ChildOrganizationIDs = new OrganizationsStructuresBLL().GetOrganizationFirstLevelByID(OrganizationID);
                    List <EVacationsRequests> ChildOrganizationIDEVacationsRequestsList = new EVacationsRequestsDAL().GetEVacationsRequestsByOrganizations(ChildOrganizationIDs).Where(x => x.EVacationRequestStatusID == (int)EVacationRequestStatusEnum.Pending &&
                                                                                                                                                                                       !x.ActualJobID.HasValue) // thats mean is manager
                                                                                          .ToList();
                    ChildOrganizationIDEVacationsRequestsList.ForEach(x => EVacationsRequestsBLLList.Add(MapEVacationRequest(x)));
                }
                #endregion

                return(EVacationsRequestsBLLList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// get authorized person to specific organization and e service type
        /// </summary>
        /// <param name="OrganizationID"></param>
        /// <param name="EServiceType"></param>
        /// <returns></returns>
        public EServicesAuthorizationsBLL GetOrganizationAuthorizedPerson(int OrganizationID, EServicesTypesEnum EServiceType)
        {
            try
            {
                EServicesAuthorizations    EServiceAuthorization     = new EServicesAuthorizationsDAL().Get(OrganizationID, (int)EServiceType).FirstOrDefault();
                EServicesAuthorizationsBLL EServicesAuthorizationBLL = null;
                if (EServiceAuthorization != null)
                {
                    EServicesAuthorizationBLL = new EServicesAuthorizationsBLL()
                    {
                        AuthorizedPerson = new EmployeesCodesBLL().MapEmployeeCode(EServiceAuthorization.AuthorizedPersonNav),
                        Organization     = new OrganizationsStructuresBLL().MapOrganizationWithoutManager(EServiceAuthorization.OrganizationsStructures),
                        EServiceType     = new EServicesTypesBLL()
                        {
                            EServiceTypeID = EServiceAuthorization.EServiceTypeID, EServiceTypeName = EServiceAuthorization.EServicesTypes.EServiceTypeName
                        }
                    }
                }
                ;

                return(EServicesAuthorizationBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public EServicesAuthorizationsBLL GetByOrganizationID(int OrganizationID, EServicesTypesEnum EServiceTypeID)
        {
            try
            {
                EServicesAuthorizations    EServiceAuthorization    = new EServicesAuthorizationsDAL().GetByOrganizationID(OrganizationID, (int)EServiceTypeID);
                EServicesAuthorizationsBLL EServiceAuthorizationBLL = new EServicesAuthorizationsBLL();

                EServiceAuthorizationBLL = new EServicesAuthorizationsBLL()
                {
                    EServiceAuthorizationID = EServiceAuthorization.EServiceAuthorizationID,
                    AuthorizedPerson        = new EmployeesCodesBLL().MapEmployeeCode(EServiceAuthorization.AuthorizedPersonNav),
                    Organization            = new OrganizationsStructuresBLL().MapOrganization(EServiceAuthorization.OrganizationsStructures),
                    EServiceType            = new EServicesTypesBLL().MapEServicesTypes(EServiceAuthorization.EServicesTypes)
                };

                return(EServiceAuthorizationBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public Result MakeDecisionOfEVacationRequest(EVacationsRequestsBLL EVacationRequestObj, EVacationRequestStatusEnum EVacationRequestStatus)
        {
            try
            {
                Result result = null;
                EVacationRequestObj.ApprovedBy = new EmployeesCodesBLL().GetByEmployeeCodeNo(EVacationRequestObj.ApprovedBy.EmployeeCodeNo);
                EVacationsRequestsBLL EVacationsRequestsData = new EVacationsRequestsBLL().GetEVacationsRequestsByEVacationRequestID(EVacationRequestObj.EVacationRequestID);

                #region Validate there is a decision of this e vacation request or not
                if (EVacationsRequestsData.EVacationRequestStatus.EVacationRequestStatusID != (int)EVacationRequestStatusEnum.Pending)
                {
                    result            = new Result();
                    result.Entity     = EVacationsRequestsData;
                    result.EnumMember = VacationsValidationEnum.RejectedBecauseOfEVacationRequestStatusNotPending.ToString();
                    return(result);
                }
                #endregion

                #region Validate the approver person is authorized to employee manager or not
                EmployeesCodesBLL ActualAuthorizedPerson = new EServicesAuthorizationsBLL().GetOrganizationAuthorizedPerson(EVacationsRequestsData.ActualEmployeeOrganization.OrganizationID, EServicesTypesEnum.Vacation).AuthorizedPerson;
                if (ActualAuthorizedPerson.EmployeeCodeNo != EVacationRequestObj.ApprovedBy.EmployeeCodeNo)
                {
                    result            = new Result();
                    result.EnumMember = VacationsValidationEnum.RejectedBeacuseOfApproverIsNotAuthorizedPerson.ToString();
                    result.Entity     = ActualAuthorizedPerson;
                    return(result);
                }
                #endregion

                string SMSMessage = string.Empty;
                // in case of approval, send the vacation data to vacations module to be added, after that change the status in e vacation requests module
                if (EVacationRequestStatus == EVacationRequestStatusEnum.Approved)
                {
                    #region Send vacation to vacations module
                    BaseVacationsBLL Vacation = new BaseVacationsBLL()
                    {
                        IsApprovedFromManager = true,
                        EVacationsRequest     = EVacationsRequestsData,
                        EmployeeCareerHistory = EVacationsRequestsData.EmployeeCareerHistory,
                        VacationType          = VacationsTypesEnum.Normal,
                        VacationStartDate     = EVacationsRequestsData.VacationStartDate,
                        VacationEndDate       = EVacationsRequestsData.VacationEndDate,
                        Notes         = EVacationsRequestsData.CreatorNotes,
                        ApprovedBy    = EVacationRequestObj.ApprovedBy,
                        LoginIdentity = EVacationsRequestsData.CreatedBy,
                        CreatedDate   = DateTime.Now,
                        IsCanceled    = false,
                    };
                    result = Vacation.Add();
                    #endregion

                    #region Update IsApproved in vacations module
                    result = Vacation.Approve();
                    #endregion

                    if (result.EnumMember == VacationsValidationEnum.Done.ToString())
                    {
                        result = ApproveEVacationRequest(EVacationRequestObj, EVacationRequestStatus);
                    }

                    SMSMessage = string.Format(Globalization.SMSEVacationRequestApprovedText, EVacationsRequestsData.VacationType.VacationTypeName, EVacationsRequestsData.VacationStartDate, EVacationsRequestsData.VacationPeriod);
                }
                else  // in case of refuse, change the status in e vacation requests module only
                {
                    result     = ApproveEVacationRequest(EVacationRequestObj, EVacationRequestStatus);
                    SMSMessage = Globalization.SMSEVacationRequestRefusedText;
                }

                #region Sending sms to employee to notify him the authorized person decision
                SMSBLL sMSBLL = new SMSBLL();
                sMSBLL.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.AuthorizedPersonDecisionForEVacationRequest,
                    DetailID           = EVacationsRequestsData.EVacationRequestID,
                    MobileNo           = EVacationsRequestsData.EmployeeCareerHistory?.EmployeeCode?.Employee?.EmployeeMobileNo,
                    Message            = SMSMessage,
                    CreatedBy          = EVacationRequestObj.ApprovedBy,
                });
                #endregion

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
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;
            }
        }
        /// <summary>
        /// Task 256: Adding records in e service authorization after adding new organization node in organizations structure
        /// Set Manager as Parent_Manager_Code_ID if manager is null
        /// </summary>
        /// <returns></returns>
        public virtual Result Add()
        {
            try
            {
                Result result = new Result();

                // TASK 256 (related) if manager is null, we set "parent manage" is also manager of newly created organization
                if (this.OrganizationManager == null)
                {
                    OrganizationsStructures ParentOrg = new OrganizationsStructuresDAL().GetByOrganizationID(this.ParentOrganization.OrganizationID);
                    if (ParentOrg != null && ParentOrg.ManagerCodeID.HasValue && ParentOrg.ManagerCodeID.Value > 0)
                    {
                        this.OrganizationManager = new EmployeesCodesBLL()
                        {
                            EmployeeCodeID = ParentOrg.ManagerCodeID.Value
                        };
                    }
                }

                OrganizationsStructures OrganizationsStructures = new OrganizationsStructures()
                {
                    BranchID             = this.Branch.BranchID,
                    OrganizationParentID = this.ParentOrganization.OrganizationID,
                    OrganizationName     = this.OrganizationName,
                    OrganizationCode     = this.OrganizationCode,
                    ManagerCodeID        = this.OrganizationManager != null && this.OrganizationManager.EmployeeCodeID != 0 ? (int)this.OrganizationManager.EmployeeCodeID : (int?)null,
                    CreatedDate          = DateTime.Now,
                    CreatedBy            = this.LoginIdentity.EmployeeCodeID
                };
                this.OrganizationID = new OrganizationsStructuresDAL().Insert(OrganizationsStructures);

                #region EService Authorization: Create EServiceAuthorization records of the Organization based on EServiceTypes
                if (this.OrganizationManager != null && this.OrganizationManager.EmployeeCodeID > 0)
                {
                    EServicesAuthorizationsBLL EServiceAuthorizationBLL;
                    foreach (var item in new EServicesTypesBLL().GetEServicesTypes())
                    {
                        EServiceAuthorizationBLL = new EServicesAuthorizationsBLL();
                        EServiceAuthorizationBLL.Organization = new OrganizationsStructuresBLL()
                        {
                            OrganizationID = this.OrganizationID
                        };
                        EServiceAuthorizationBLL.AuthorizedPerson = new EmployeesCodesBLL()
                        {
                            EmployeeCodeID = this.OrganizationManager.EmployeeCodeID
                        };
                        EServiceAuthorizationBLL.EServiceType  = item;
                        EServiceAuthorizationBLL.CreatedDate   = DateTime.Now;
                        EServiceAuthorizationBLL.LoginIdentity = this.LoginIdentity;
                        EServiceAuthorizationBLL.Add();
                    }
                }
                #endregion

                result.Entity     = this;
                result.EnumType   = typeof(OrganizationStructureValidationEnum);
                result.EnumMember = OrganizationStructureValidationEnum.Done.ToString();
                return(result);
            }
            catch
            {
                throw;
            }
        }