コード例 #1
0
        public async Task <IActionResult> GetEmployeesById(int id, int page)
        {
            int pageSize = 3;

            try
            {
                var employees = await _employeeProvider.GetEmployeesByDepartmentIdAsync(id);

                var count = employees.Count;
                var items = employees.Skip((page - 1) * pageSize).Take(pageSize).ToList();

                PageViewModel         pageViewModel         = new PageViewModel(count, page, pageSize);
                EmployeePageViewModel employeePageViewModel = new EmployeePageViewModel
                {
                    PageViewModel = pageViewModel,
                    Employees     = employees
                };

                return(Ok(employeePageViewModel));
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }