Exemplo n.º 1
0
        public List <Department> GetDepartments()
        {
            const string query = @"SELECT [Id]
                                        ,[DepartmentName]
                                    FROM [viDepartment]";

            using (var con = _dbHelper.GetConnection())
            {
                var departments = con.Query <Department>(query).ToList();
                foreach (var department in departments)
                {
                    // TODO: set users
                    department.Users = _userRepository.GetDepartmentUser(department.Id);

                    foreach (var user in department.Users)
                    {
                        user.ConfirmedVacationSlots = _vacationRepository.GetConfirmedVacationSlotsFromUser(user.Id);
                    }
                }

                return(departments);
            }
        }