public override Result Add() { try { Result result = null; #region Validation for vacation creation during probation period //EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); //if (HiringRecord != null) //{ // // probation period = hiring date + 1 year // DateTime ProbationEndDate = HiringRecord.ProbationEndDate; //Globals.Calendar.AddYearMonthDayInUmAlQuraDate(HiringRecord.JoinDate, 1, 0, 0); // HiringRecord.JoinDate.AddYears(1).AddDays(-10); // if (ProbationEndDate > this.VacationStartDate) // { // result = new Result(); // result.Entity = HiringRecord; // result.EnumType = typeof(VacationsValidationEnum); // result.EnumMember = VacationsValidationEnum.RejectedBecauseOfDuringProbation.ToString(); // return result; // } //} #endregion #region Validation for balanace result = IsBalanceValid(); if (result != null) { return(result); } //result = IsNormalVacationExistsAndConsumedMaxLimit(); //if (result != null) // return result; #endregion #region Validation for if employee has normal balance and he does not work as a teacher // check employee works as a teacher or not ... if he works as a teacher, he can get exceptional vacation even if he has normal vacation balance or not bool IsEmployeeWorksAsTeacher = new TeachersBLL().IsEmployeeWorksAsTeacher(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, this.VacationStartDate, this.VacationEndDate); if (!IsEmployeeWorksAsTeacher) { result = IsNormalVacationExistsAndConsumedMaxLimit(); if (result != null) { return(result); } } #endregion #region base validation result = base.Add(); #endregion return(result); } catch (Exception ex) { throw ex; } }
public virtual TeachersBLL GetByTeacherID(int TeacherID) { try { TeachersBLL TeacherBLL = null; Teachers Teacher = new TeachersDAL().GetByTeacherID(TeacherID); if (Teacher != null) { TeacherBLL = new TeachersBLL().MapTeacher(Teacher); } return(TeacherBLL); } catch { throw; } }
internal TeachersBLL MapTeacher(Teachers Teacher) { try { TeachersBLL TeacherBLL = null; if (Teacher != null) { TeacherBLL = new TeachersBLL() { TeacherID = Teacher.TeacherID, EmployeeCareerHistory = Teacher.EmployeesCareersHistory != null ? new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(Teacher.EmployeesCareersHistory) : null, StartDate = Teacher.StartDate, EndDate = Teacher.EndDate, CreatedDate = Teacher.CreatedDate, CreatedBy = new EmployeesCodesBLL().MapEmployeeCode(Teacher.EmployeesCodes) }; } return(TeacherBLL); } catch { throw; } }