public Result Remove(int EndOfServiceID) { try { Result result = null; EndOfServicesBLL EndOfService = GetByEndOfServiceID(EndOfServiceID); if (EndOfService.EndOfServiceDate <= DateTime.Now.Date) { result = new Result(); result.Entity = this; result.EnumMember = EndOfServicesValidationEnum.RejectedBecauseOfEndOfServicesDateIsPassedAway.ToString(); result.EnumType = typeof(EndOfServicesValidationEnum); return(result); } new EndOfServicesDAL().Delete(EndOfServiceID, this.LoginIdentity.EmployeeCodeID); return(result = new Result() { EnumType = typeof(EndOfServicesValidationEnum), EnumMember = EndOfServicesValidationEnum.Done.ToString() }); } catch { throw; } }
public virtual Result Add() { Result result = null; result = new Result(); #region Check if vacation after his endOfService date. EndOfServicesBLL EndOfServicesBLL = new EndOfServicesBLL().GetByEndOfServiceID(this.EndOfService.EndOfServiceID); if (EndOfServicesBLL.EndOfServiceDate < this.VacationEndDate) { result.Entity = this; result.EnumType = typeof(EndOfServicesVacationsValidationEnum); result.EnumMember = EndOfServicesVacationsValidationEnum.RejectedBecauseOfVacationEndDateBiggerThanEndOfServiceDate.ToString(); return(result); } #endregion EndOfServicesVacations EndOfServiceVacation = new EndOfServicesVacations(); EndOfServiceVacation.VacationStartDate = this.VacationStartDate; EndOfServiceVacation.VacationEndDate = this.VacationEndDate; EndOfServiceVacation.EndOfServiceID = this.EndOfService.EndOfServiceID; EndOfServiceVacation.VacationTypeID = this.VacationType.VacationTypeID; EndOfServiceVacation.CreatedDate = DateTime.Now; EndOfServiceVacation.CreatedBy = this.LoginIdentity.EmployeeCodeID; this.EndOfServiceVacationID = new EndOfServicesVacationsDAL().Insert(EndOfServiceVacation); if (this.EndOfServiceVacationID != 0) { result.Entity = this; result.EnumType = typeof(LookupsValidationEnum); result.EnumMember = LookupsValidationEnum.Done.ToString(); } return(result); }
/// <summary> /// This function called by Windows services and schedule to run on daily basis /// This function to get all EOS records from EOStable with isprocessed null/0 and EOSDate is <= Current Date /// Following action is performed: /// 1 - Create Employee Career History record for EOS type /// 2 - Deactivate all Employee Career History records of each EOS record /// 3 - Deactivate employee /// 4 - Set Job as Vacant /// 5 - Mark isProcessed = 1 after successful of above 4 steps /// </summary> /// <returns></returns> public virtual Result StartProcess() { try { Result result = new Result(); List <EndOfServicesBLL> EndOfServicesNotProcessed = this.GetEndOfServicesNotProcessed(); foreach (EndOfServicesBLL item in EndOfServicesNotProcessed) { if (DateTime.Now.Date >= item.EndOfServiceDate.Date) { #region Adding new record with new career history type End of service EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().Get(item.EmployeeCareerHistory.OrganizationJob, CareersHistoryTypesEnum.EndOfService, item.EmployeeCareerHistory.EmployeeCode); if (EmployeeCareerHistory == null) { result = new EmployeesCareersHistoryBLL() { EmployeeCode = item.EmployeeCareerHistory.EmployeeCode, OrganizationJob = item.EmployeeCareerHistory.OrganizationJob, CareerHistoryType = new CareersHistoryTypesBLL() { CareerHistoryTypeID = (int)CareersHistoryTypesEnum.EndOfService }, CareerDegree = item.EmployeeCareerHistory.CareerDegree, JoinDate = item.EndOfServiceDate, TransactionStartDate = item.EndOfServiceDate, IsActive = false, LoginIdentity = item.CreatedBy, }.Add(); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } else { #region Deactivate all career history of employee new EmployeesCareersHistoryBLL() { LoginIdentity = item.CreatedBy }.DeactivateAllCareerHistoryOfEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); #endregion } } #endregion #region Deactivate employee result = new EmployeesCodesBLL() { LoginIdentity = item.CreatedBy }.DeactivateEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } #endregion #region Set his job as job vacant result = new OrganizationsJobsBLL() { LoginIdentity = item.CreatedBy }.SetJobAsVacant(item.EmployeeCareerHistory.OrganizationJob.OrganizationJobID); #endregion #region Update is process to true result = new EndOfServicesBLL() { LoginIdentity = item.CreatedBy }.MarkIsProcessToDone(item.EndOfServiceID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } #endregion } } return(result); } catch (Exception ex) { throw ex; } }