/// <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; } }
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; } }
internal Result IsEVacationRequestPendingExist(string EmployeeCodeNo) { Result result = null; EVacationsRequestsBLL PendingEVacationsRequests = GetEVacationsRequestsBasedOnStatus(EmployeeCodeNo, EVacationRequestStatusEnum.Pending).FirstOrDefault(); if (PendingEVacationsRequests != null) { result = new Result(); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfEVacationRequestPendingExist.ToString(); this.EVacationRequestNo = PendingEVacationsRequests.EVacationRequestNo; result.Entity = this; } return(result); }
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; } }
public EVacationsRequestsBLL GetEVacationsRequestsByEVacationRequestID(int EVacationRequestID) { try { EVacationsRequests EVacationRequest = new EVacationsRequestsDAL().GetByEVacationRequestID(EVacationRequestID); EVacationsRequestsBLL EVacationRequestBLL = null; if (EVacationRequest != null) { EVacationRequestBLL = MapEVacationRequest(EVacationRequest); } // if the request still pending , we will show who the person that authorize to take decision for this request if (EVacationRequest.EVacationRequestStatusID == (int)EVacationRequestStatusEnum.Pending) { EVacationRequestBLL.ApprovedBy = new EmployeesCodesBLL().GetEVacationAuthorizedPersonOfEmployee(EVacationRequestBLL.CreatedBy.EmployeeCodeNo, EServicesTypesEnum.Vacation); } return(EVacationRequestBLL); } catch (Exception ex) { throw ex; } }
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; } }
//public BaseAssigningsBLL GetActiveAssigningByEmployeeCareerHistoryID(int EmployeeCareerHistoryID) //{ // BaseAssigningsBLL assigningBLL = new BaseAssigningsBLL(); // Assignings assigning = new AssigningsDAL().GetActiveAssigningByEmployeeCareerHistoryID(EmployeeCareerHistoryID); // if (assigning != null) // assigningBLL = new BaseAssigningsBLL().MapAssigning(assigning); // return assigningBLL; //} /// <summary> /// Task # 226 : /// Finish last assigning, based on passing parameters /// this function called by different modules like Promotion, Delegation, or StopWork etc /// Task # 310 : change CareerHistoryID to EmployeeCodeID because of task 310 /// Task 318: Service to Cancel EServicesProxies By System /// </summary> /// <param name="EmployeeCodeID"></param> /// <param name="AssigningEndDate"></param> /// <param name="EndAssigningReason"></param> /// <returns></returns> public Result BreakLastAssigning(int EmployeeCodeID, DateTime AssigningEndDate, AssigningsReasonsEnum EndAssigningReason, string EndAssigningReasonNotes = "") { Result result = new Result(); BaseAssigningsBLL assigningBLL = new BaseAssigningsBLL(); Assignings assigning = new AssigningsDAL().GetActiveAssigningByEmployeeCodeID(EmployeeCodeID); if (assigning != null) { if (assigning.IsFinished) { result.Entity = this; result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.Done.ToString(); return(result); } if (AssigningEndDate < assigning.AssigningStartDate) { result = new Result(); result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString(); return(result); } assigning.AssigningEndDate = AssigningEndDate; assigning.EndAssigningReasonID = (int)EndAssigningReason; assigning.IsFinished = true; assigning.Notes = EndAssigningReasonNotes; assigning.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; assigning.LastUpdatedDate = DateTime.Now; this.AssigningID = new AssigningsDAL().BreakAssigning(assigning); if (this.AssigningID != 0) { #region Cancellation of all pending e vacations requests of employee after breaking last assigning of him List <EVacationsRequests> PendingEVacationRequestsList = new EVacationsRequestsDAL().GetByEmployeeCodeID(EmployeeCodeID, (int)EVacationRequestStatusEnum.Pending); foreach (var item in PendingEVacationRequestsList) { result = new EVacationsRequestsBLL().CancelEVacationRequest(item.EVacationRequestID, EVacationRequestStatusEnum.CancelledBySystem, Globalization.EVacationRequestCancelledBySystemBecauseOfBreakingLastAssigningText); } #endregion #region Task 318: Service to Cancel EServicesProxies By System try { result = new EServicesProxiesBLL() { LoginIdentity = this.LoginIdentity } .RevokeEServiceProxyByEmployeeCodeID(EmployeeCodeID, EServicesProxiesStatusEnum.CancelledBySystem, Globalization.EServiceProxyCancelledBySystemBecauseOfBreakingLastAssigningText); } catch (Exception ex) { throw ex; } #endregion result.Entity = this; result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.Done.ToString(); } } else { result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.RejectedBecauseAssigningNotFound.ToString(); } return(result); }
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; } }