Example #1
0
        public EmployesFlexibility GetFlexibilityComposition()
        {
            List <EmployeDto> allEmployesWithArea = _employeService.GetAllWithAreaNotNull().ToList();
            List <EmployeDto> allEmployesNoArea   = _employeService.GetAllWithAreaNull().ToList();
            List <AreaDto>    areas      = _areaService.GetAllWithEmploye().ToList();
            List <EmployeDto> inflexible = new List <EmployeDto>();

            foreach (AreaDto a in areas)
            {
                if (a.EmployeList.Count == 1)
                {
                    allEmployesWithArea.Remove(allEmployesWithArea.FirstOrDefault(e => e.Id == a.EmployeList[0].Id));
                    a.EmployeList[0].State = EmployeState.Inflexible;
                    inflexible.Add(new EmployeDto(a.EmployeList[0]));
                }
            }

            return(new EmployesFlexibility(GetFlexibleEmployes(allEmployesWithArea, areas), inflexible.Distinct().OrderBy(e => e.Surname).ToList(), allEmployesNoArea));
        }