private float GetVacationBalanceByEmployeeCodeID(int EmployeeCodeID) { //return this.GetByEmployeeCodeVacationTypeNotCanceled(EmployeeCodeID) // .ToList().Sum(d => d.VacationPeriod); if (this.HolidayAttendanceDetail.HolidaysAttendance != null) { HolidaysSettingsBLL HolidaySetting; if (this.HolidayAttendanceDetail.HolidaysAttendance.HolidaySetting == null) { HolidaysAttendanceBLL HolidayAttendance = new HolidaysAttendanceBLL().GetByHolidayAttendanceID(this.HolidayAttendanceDetail.HolidaysAttendance.HolidayAttendanceID); HolidaySetting = HolidayAttendance.HolidaySetting;//new HolidaysSettingsBLL().GetByHolidaySettingID(HolidayAttendance.HolidaySetting.HolidaySettingID); this.HolidayAttendanceDetail.HolidaysAttendance.HolidaySetting = HolidaySetting; } //HolidaysSettingsBLL HolidaySetting = new HolidaysSettingsBLL().GetByMaturityYearIDAndHolidayTypeID(this.MaturityYear.MaturityYearID, this.HolidayType.HolidayTypeID); HolidaySetting = new HolidaysSettingsBLL().GetByMaturityYearIDAndHolidayTypeID(this.HolidayAttendanceDetail.HolidaysAttendance.HolidaySetting.MaturityYear.MaturityYearID, this.HolidayAttendanceDetail.HolidaysAttendance.HolidaySetting.HolidayType.HolidayTypeID); if (HolidaySetting != null) { List <HolidaysAttendanceBLL> HolidayAttendanceList = new HolidaysAttendanceBLL().GetByHolidaySettingID(HolidaySetting.HolidaySettingID); if (HolidayAttendanceList != null) { List <HolidaysAttendanceDetailsBLL> HolidaysAttendanceDetailsList = new List <HolidaysAttendanceDetailsBLL>(); HolidayAttendanceList.ForEach(c => HolidaysAttendanceDetailsList.AddRange(c.HolidaysAttendanceDetails.ToList())); //this.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(EmployeeCodeID); //{ EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = EmployeeCodeID } this.EmployeeCareerHistory = new EmployeesCodesBLL().GetCareerHistoryByEmployeeCodeID(EmployeeCodeID).FirstOrDefault(c => c.IsActive == true); //{ EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = EmployeeCodeID } if (HolidaysAttendanceDetailsList.Any(x => x.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID == EmployeeCodeID)) { return(HolidaySetting != null?HolidaySetting.HolidaySettingEndDate.Subtract(HolidaySetting.HolidaySettingStartDate).Days + 1 : 0); } } } } return(0); }
public HolidaysSettingsBLL GetByHolidaySettingID(int HolidaySettingID) { HolidaysSettingsBLL HolidaySettingBLL = null; HolidaysSettings HolidaySetting = new HolidaysSettingsDAL().GetByHolidaySettingID(HolidaySettingID); if (HolidaySetting != null) { HolidaySettingBLL = new HolidaysSettingsBLL().MapHolidaySetting(HolidaySetting); } return(HolidaySettingBLL); }
public override Result Add() { try { Result result = new Result(); if (this.HolidayAttendanceDetail == null) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfNoBalance.ToString(); return(result); } #region Validation for balanace result = IsBalanceValid(); if (result != null) { return(result); } #endregion #region Validate if Vacation pass more than 1 year or Vacation startDate Less than holiday's EndDate HolidaysSettingsBLL HolidaySetting = new HolidaysSettingsBLL(); HolidaySetting = new HolidaysAttendanceBLL().GetByHolidayAttendanceID(this.HolidayAttendanceDetail.HolidaysAttendance.HolidayAttendanceID).HolidaySetting; DateTime?ExpireHoldaySettingDate = this.VacationExpiredDate; bool IsExpire = this.VacationEndDate > ExpireHoldaySettingDate || this.VacationStartDate < HolidaySetting.HolidaySettingEndDate; if (IsExpire) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfVacationOutOfRange.ToString(); return(result); } #endregion #region base validation result = base.Add(); if (result != null) { return(result); } #endregion return(result); } catch { throw; } }
public override Result Edit() { this.EmployeeCareerHistory = this.GetByVacationID(this.VacationID).EmployeeCareerHistory; // to get EmployeeCodeID Result result = null; #region Validation for balanace result = IsBalanceValid(this.VacationID); if (result != null) { return(result); } #endregion #region Validation for he was assigned in any holiday aatendance detail or not if (this.HolidayAttendanceDetail == null) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfNoBalance.ToString(); return(result); } #endregion #region Validate if Vacation pass more than 1 year or Vacation startDate Less than holiday's EndDate HolidaysSettingsBLL HolidaySetting = new HolidaysSettingsBLL(); HolidaySetting = new HolidaysAttendanceBLL().GetByHolidayAttendanceID(this.HolidayAttendanceDetail.HolidaysAttendance.HolidayAttendanceID).HolidaySetting; DateTime ExpireHoldaySettingDate = HolidaySetting.HolidaySettingEndDate.AddYears(1); bool IsExpire = this.VacationEndDate > ExpireHoldaySettingDate || this.VacationStartDate < HolidaySetting.HolidaySettingEndDate; if (IsExpire) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfVacationOutOfRange.ToString(); return(result); } #endregion #region base validation result = base.Edit(); if (result != null) { return(result); } #endregion return(result); }
public HolidaysAttendanceDetailsBLL GetHolidayAttendanceDetailByEmployeeCodeIDAndHolidayTypeIDAndHolidaySettingID(int EmployeeCodeID, int MaturityYearID, int HolidayTypeID) { HolidaysSettingsBLL HolidaySetting = new HolidaysSettingsBLL().GetByMaturityYearIDAndHolidayTypeID(MaturityYearID, HolidayTypeID); if (HolidaySetting != null) { List <HolidaysAttendanceBLL> HolidayAttendanceList = new HolidaysAttendanceBLL().GetByHolidaySettingID(HolidaySetting.HolidaySettingID); //if List <HolidaysAttendanceDetailsBLL> HolidaysAttendanceDetailsList = new List <HolidaysAttendanceDetailsBLL>(); HolidayAttendanceList.ForEach(c => HolidaysAttendanceDetailsList.AddRange(c.HolidaysAttendanceDetails.ToList())); //EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(EmployeeCodeID); //{ EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = EmployeeCodeID } EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCodesBLL().GetCareerHistoryByEmployeeCodeID(EmployeeCodeID).FirstOrDefault(c => c.IsActive == true); //{ EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = EmployeeCodeID } var result = HolidaysAttendanceDetailsList.FirstOrDefault(x => x.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID == EmployeeCodeID); return(result); } else { return(null); } }
public HolidaysSettingsBLL GetByMaturityYearIDAndHolidayTypeID(int MaturityYearID, int HolidayTypeID) { HolidaysSettingsBLL HolidaySettingBLL = GetHolidaysSettings().FirstOrDefault(x => x.MaturityYear.MaturityYearID == MaturityYearID && x.HolidayType.HolidayTypeID == HolidayTypeID); return(HolidaySettingBLL); }