public IEnumerable <LoadInCourseFact> DistributeLoad(IEnumerable <LoadInCoursePlan> loadIsOwner, bool saveData) { var loadInCourseFact = new List <LoadInCourseFact>(); foreach (var load in loadIsOwner) { var emp = load.OwnerIsCourse; if (emp != null) { if (!emp.NonActive && emp.CheckFreeHourse(load.CountHours)) { var lf = new LoadInCourseFact() { CountHours = load.CountHours, LoadInCoursePlanID = load.Id, EmployeeID = emp.Id, Approved = true, ClassRoomID = _repository.GetClassRoomIDAtPreviousYears(load) }; loadInCourseFact.Add(lf); if (saveData) { _repository.AddLoadInCourseFact(lf); } } } } return(loadInCourseFact); }
public IEnumerable <LoadInCourseFact> DistributeLoadIsOwner(IEnumerable <LoadInCoursePlan> loadLab, bool saveData) { var loadInCourseFact = new List <LoadInCourseFact>(); foreach (var load in loadLab) { Employee emp = load.OwnerIsCourse; int countEmployee = load.CourseInWork.IsDivisionLab ? 2 : 1; if (emp != null) { if (!emp.NonActive && emp.CheckFreeHourse(load.CountHours)) { var lf = new LoadInCourseFact() { CountHours = load.CountHours / countEmployee, LoadInCoursePlanID = load.Id, EmployeeID = emp.Id, Approved = null, ClassRoomID = _repository.GetClassRoomIDAtPreviousYears(load) }; loadInCourseFact.Add(lf); _repository.AddLoadInCourseFact(lf); } } } return(loadInCourseFact); }
public IEnumerable <LoadInCourseFact> DistributeLoad(IEnumerable <LoadInCoursePlan> load, bool saveData) { var loadInCourseFact = new List <LoadInCourseFact>(); foreach (var l in load) { Employee empOwner = l.OwnerIsCourse; Employee emp = empOwner; int priority = 0; if (empOwner != null) { do { if (!emp.NonActive && _repository.CheckFreeHourse(emp, l.CountHours)) { var lf = new LoadInCourseFact() { CountHours = l.CountHours, LoadInCoursePlanID = l.Id, EmployeeID = emp.Id, Approved = null, ClassRoomID = _repository.GetClassRoomIDAtPreviousYears(l) }; loadInCourseFact.Add(lf); if (saveData) { _repository.AddLoadInCourseFact(lf); } priority = 0; } else { emp = empOwner.GetEmployeeWorkTogether(++priority) ?? _repository.GetEmployeeLowLoad()?.LastOrDefault() ?? empOwner; } } while (priority != 0); } } return(loadInCourseFact); }