Exemplo n.º 1
0
        /// <summary>
        /// Update data in EVacation Requests table , then Send the vacation details to Vacations module to be added
        /// </summary>
        /// <returns></returns>
        private Result ApproveEVacationRequest(EVacationsRequestsBLL EVacationRequestObj, EVacationRequestStatusEnum EVacationRequestStatus)
        {
            try
            {
                Result result;

                EVacationsRequests EVacationRequest = new EVacationsRequests()
                {
                    EVacationRequestID       = EVacationRequestID,
                    EVacationRequestStatusID = (int)EVacationRequestStatus,
                    ApprovalDateTime         = DateTime.Now,
                    ApproverNotes            = EVacationRequestObj.ApproverNotes,
                    ApprovedBy      = EVacationRequestObj.ApprovedBy.EmployeeCodeID,
                    LastUpdatedDate = DateTime.Now,
                    LastUpdatedBy   = EVacationRequestObj.ApprovedBy.EmployeeCodeID
                };

                result = new Result();

                new EVacationsRequestsDAL().Update(EVacationRequest);
                result.Entity     = this;
                result.EnumMember = VacationsValidationEnum.Done.ToString();

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public Result CancelEVacationRequest(int EVacationRequestID, EVacationRequestStatusEnum CancelledBy, string CancellationReason = "")
        {
            try
            {
                Result result;
                EVacationsRequestsBLL EVacationRequestObj = new EVacationsRequestsBLL().GetEVacationsRequestsByEVacationRequestID(EVacationRequestID);

                #region Validation if Authorized person approved or rejected, no chance to cancel vacation after decision from Authorized person
                if (EVacationRequestObj.EVacationRequestStatus?.EVacationRequestStatusID != (int)EVacationRequestStatusEnum.Pending)
                {
                    result            = new Result();
                    result.Entity     = this;
                    result.EnumMember = VacationsValidationEnum.RejectedBecauseOfEVacationRequestStatusNotPending.ToString();
                    return(result);
                }
                #endregion

                #region Changing status of eservice request
                EVacationsRequests EVacationRequest = new EVacationsRequests()
                {
                    EVacationRequestID       = EVacationRequestID,
                    EVacationRequestStatusID = (int)CancelledBy,
                    CancellationReasonByHR   = CancellationReason,
                    LastUpdatedDate          = DateTime.Now,
                    LastUpdatedBy            = CancelledBy == EVacationRequestStatusEnum.CancelledByHR ? this.LoginIdentity.EmployeeCodeID : EVacationRequestObj.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
                };

                result = new Result();

                new EVacationsRequestsDAL().UpdateStatus(EVacationRequest);
                result.Entity     = this;
                result.EnumMember = VacationsValidationEnum.Done.ToString();
                #endregion

                #region If cancellation by HR, Sending sms to employee to notify him
                if (CancelledBy == EVacationRequestStatusEnum.CancelledByHR || CancelledBy == EVacationRequestStatusEnum.CancelledBySystem)
                {
                    SMSBLL sMSBLL = new SMSBLL();
                    sMSBLL.SendSMS(new SMSLogsBLL()
                    {
                        BusinssSubCategory = BusinessSubCategoriesEnum.AuthorizedPersonDecisionForEVacationRequest,
                        DetailID           = EVacationRequestObj.EVacationRequestID,
                        MobileNo           = EVacationRequestObj.EmployeeCareerHistory.EmployeeCode.Employee.EmployeeMobileNo,
                        Message            = string.Format(Globalization.SMSEVacationRequestCancelledByHrText),
                        CreatedBy          = EVacationRequestObj.ApprovedBy,
                    });
                }
                #endregion

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
 internal EVacationsRequestsBLL MapEVacationRequest(EVacationsRequests EVacationRequest)
 {
     try
     {
         EVacationsRequestsBLL EVacationRequestBLL = null;
         if (EVacationRequest != null)
         {
             EVacationRequestBLL = new EVacationsRequestsBLL()
             {
                 EVacationRequestID         = EVacationRequest.EVacationRequestID,
                 EVacationRequestNo         = EVacationRequest.EVacationRequestNo,
                 VacationType               = new VacationsTypesBLL().MapVacationsTypes(EVacationRequest.VacationsTypes),
                 VacationStartDate          = EVacationRequest.VacationStartDate,
                 VacationEndDate            = EVacationRequest.VacationEndDate,
                 EmployeeCareerHistory      = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EVacationRequest.EmployeesCareersHistory),
                 ActualEmployeeOrganization = new OrganizationsStructuresBLL().MapOrganizationWithoutManager(EVacationRequest.OrganizationsStructures),
                 ActualEmployeeJob          = new JobsBLL().MapJob(EVacationRequest.Jobs),
                 EVacationRequestStatus     = new EVacationRequestStatusBLL()
                 {
                     EVacationRequestStatusID = EVacationRequest.EVacationRequestStatusID.Value, EVacationRequestStatusName = EVacationRequest.EVacationRequestsStatus.EVacationRequestStatusName
                 },
                 CreatorNotes           = EVacationRequest.CreatorNotes,
                 ApprovedBy             = new EmployeesCodesBLL().MapEmployeeCode(EVacationRequest.ApprovedByNav),
                 ApprovalDateTime       = EVacationRequest.ApprovalDateTime,
                 ApproverNotes          = EVacationRequest.ApproverNotes,
                 CancellationReasonByHR = EVacationRequest.CancellationReasonByHR,
                 CreatedBy       = new EmployeesCodesBLL().MapEmployeeCode(EVacationRequest.CreatedByNav),
                 CreatedDate     = EVacationRequest.CreatedDate,
                 LastUpdatedBy   = new EmployeesCodesBLL().MapEmployeeCode(EVacationRequest.LastUpdatedByNav),
                 LastUpdatedDate = EVacationRequest.LastUpdatedDate
             };
         }
         return(EVacationRequestBLL);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
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;
            }
        }