コード例 #1
0
        public ActionResult VacationApproval(string VacationID, string ApprovalType)
        {
            BaseVacationsBLL Vacation = new BaseVacationsBLL()
            {
                VacationID    = int.Parse(VacationID),
                LoginIdentity = this.UserIdentity
            };
            Result result = new Result();

            if (ApprovalType == "Approve")
            {
                result = Vacation.Approve();
            }
            else
            {
                result = Vacation.ApproveCancel();
            }

            return(View());
        }
コード例 #2
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;
            }
        }