Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        public bool SendMessage(BusinessSubCategoriesEnum BusinessSubCategory, string Message, string EmployeeMobileNo)
        {
            SMSLogsBLL SmsLogBLL = new SMSLogsBLL()
            {
                BusinssSubCategory = BusinessSubCategory,
                MobileNo           = EmployeeMobileNo,
                DetailID           = 0,
                Message            = Message,
                CreatedBy          = this.LoginIdentity,
                CreatedDate        = DateTime.Now,
            };

            SMSBLL SmsLog = new SMSBLL();
            bool   IsSent = SmsLog.SendSMS(SmsLogBLL);

            return(IsSent);
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
        public virtual Result Add()
        {
            try
            {
                Result result = new Result();

                if (this.StartDate.ToString().Contains("0001"))
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseStartDateRequried.ToString();

                    return(result);
                }
                else if (this.LoginIdentity.EmployeeCodeID == this.ToEmployee.EmployeeCodeID)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseLoginManagerIsSameAsProxyEmployee.ToString();

                    return(result);
                }
                else
                {
                    EServicesProxiesBLL bll = this.GetActiveByFromEmployeeCodeID(this.FromEmployee.EmployeeCodeID, (EServicesTypesEnum)this.EServiceType.EServiceTypeID);
                    if (bll != null && bll.EServiceProxyID > 0)
                    {
                        result            = new Result();
                        result.Entity     = bll;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsAlreadyActiveProxyExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already EVacation Request Pending Exist
                    EmployeesCodes ToEmployee = new EmployeesCodesDAL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                    result = new EVacationsRequestsBLL().IsEVacationRequestPendingExist(ToEmployee.EmployeeCodeNo);
                    if (result != null)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsPendingEVacationRequestExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already Vacation Exist
                    List <BaseVacationsBLL> lst = new BaseVacationsBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID, this.StartDate, this.StartDate.AddDays(this.DaysCountInGregYear));
                    if (lst.Count > 0)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsVacationExist.ToString();

                        return(result);
                    }
                }

                EServicesProxies EServiceProxy = new EServicesProxies()
                {
                    EServiceTypeID        = this.EServiceType.EServiceTypeID,
                    FromEmployeeCodeID    = this.FromEmployee.EmployeeCodeID,
                    ToEmployeeCodeID      = this.ToEmployee.EmployeeCodeID,
                    StartDate             = this.StartDate,
                    EndDate               = this.EndDate,
                    EServiceProxyStatusID = (int)EServicesProxiesStatusEnum.Valid,
                    IsActive              = true,
                    Notes       = this.Notes,
                    CreatedDate = DateTime.Now,
                    CreatedBy   = this.LoginIdentity.EmployeeCodeID
                };

                this.EServiceProxyID = new EServicesProxiesDAL().Insert(EServiceProxy);

                #region Send SMS on creation
                EmployeesCodesBLL FromEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.FromEmployee.EmployeeCodeID);
                EmployeesCodesBLL ToEmployeeCodeBLL   = new EmployeesCodesBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                SMSBLL            SMSObj = new SMSBLL();
                SMSObj.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies,
                    DetailID           = this.EServiceProxyID,
                    MobileNo           = ToEmployeeCodeBLL.Employee.EmployeeMobileNo,
                    Message            = string.Format(Globalization.SMSEServicesProxiesCreationText,
                                                       ToEmployeeCodeBLL.Employee.EmployeeNameAr, FromEmployeeCodeBLL.Employee.EmployeeNameAr),
                    CreatedBy = this.LoginIdentity,
                });
                #endregion

                result            = new Result();
                result.Entity     = this;
                result.EnumType   = typeof(EServicesProxiesEnum);
                result.EnumMember = EServicesProxiesEnum.Done.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        public Result RevokeEServiceProxy(int EServiceProxyID, EServicesProxiesStatusEnum Status, string CancellationReason = "")
        {
            try
            {
                Result result = new Result();

                EServicesProxies EServiceProxy = new EServicesProxiesDAL().GetActiveByEServiceProxyID(EServiceProxyID);
                if (EServiceProxy == null || EServiceProxy.EServiceProxyID <= 0)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesAuthorizationsEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseEServiceProxyIsNotActive.ToString();

                    return(result);
                }

                int ToEmployeeCodeID   = EServiceProxy.ToEmployeeCodeID;
                int FromEmployeeCodeID = EServiceProxy.FromEmployeeCodeID;
                EServiceProxy = new EServicesProxies()
                {
                    EServiceProxyID       = EServiceProxyID,
                    EndDate               = DateTime.Now,
                    EServiceProxyStatusID = (int)Status,
                    IsActive              = false,
                    CancellationReason    = CancellationReason,
                    LastUpdatedDate       = DateTime.Now,
                    LastUpdatedBy         = this.LoginIdentity.EmployeeCodeID
                };

                this.EServiceProxyID = new EServicesProxiesDAL().Revoke(EServiceProxy);

                #region Send SMS on revoke to "ToEmployee"
                EmployeesCodesBLL FromEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(FromEmployeeCodeID);
                EmployeesCodesBLL ToEmployeeCodeBLL   = new EmployeesCodesBLL().GetByEmployeeCodeID(ToEmployeeCodeID);
                SMSBLL            SMSObj = new SMSBLL();
                SMSObj.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies,
                    DetailID           = this.EServiceProxyID,
                    MobileNo           = ToEmployeeCodeBLL.Employee.EmployeeMobileNo,
                    Message            = string.Format(Globalization.SMSEServicesProxiesRevokeText,
                                                       ToEmployeeCodeBLL.Employee.EmployeeNameAr, FromEmployeeCodeBLL.Employee.EmployeeNameAr),
                    CreatedBy = this.LoginIdentity,
                });
                #endregion

                #region Send SMS on revoke to "FromEmployee" in case of Proxy cancelled by System
                if (Status == EServicesProxiesStatusEnum.CancelledBySystem)
                {
                    SMSObj.SendSMS(new SMSLogsBLL()
                    {
                        BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies,
                        DetailID           = this.EServiceProxyID,
                        MobileNo           = FromEmployeeCodeBLL.Employee.EmployeeMobileNo,
                        Message            = string.Format(Globalization.SMSEServicesProxiesRevokeBySytemText,
                                                           FromEmployeeCodeBLL.Employee.EmployeeNameAr, CancellationReason),
                        CreatedBy = this.LoginIdentity,
                    });
                }
                #endregion

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