public IActionResult GetPage(int requestedPage)
        {
            const int elementsPerPage = 10;

            if (requestedPage < 1)
            {
                return(BadRequest($"{nameof(requestedPage)} must be at least 1."));
            }

            // Calculate Pages
            int lastPage = new CustomerSC().CalculateLastPage(elementsPerPage);
            Pagination <CustomerContactInfoDTO> response = new(requestedPage, lastPage);

            if (lastPage == 0)
            {
                return(Ok(response));
            }

            // Get Selected Page
            IQueryable <Customer>         dbCustomers = new CustomerSC().GetPage(elementsPerPage, (int)response.CurrentPage);
            List <CustomerContactInfoDTO> customers   = BaseSC.MaterializeIQueryable <Customer, CustomerContactInfoDTO>(dbCustomers);

            // Attach elements of the page to the response
            response.ResponseList = customers;

            return(Ok(response));
        }
Exemplo n.º 2
0
        public IActionResult GetPage([PositiveInteger] int requestedPage)
        {
            const int elementsPerPage = 10;

            // Cálculo de las Páginas.
            int lastPage = new EmployeeSC().CalculateLastPage(elementsPerPage);
            Pagination <EmployeePersonalInfoDTO> response = new(requestedPage, lastPage);

            if (lastPage == 0)
            {
                return(Ok(response));
            }

            // Selección de la página solicitada.
            IQueryable <Employee> dbEmployees = new EmployeeSC()
                                                .GetPage(elementsPerPage, (int)response.CurrentPage);

            // Materialización de los registros.
            List <EmployeePersonalInfoDTO> employees = BaseSC
                                                       .MaterializeIQueryable <Employee, EmployeePersonalInfoDTO>(dbEmployees);

            // Los registros se añaden a la respuesta.
            response.ResponseList = employees;

            return(Ok(response));
        }
        public IActionResult GetPage(int requestedPage)
        {
            const int elementsPerPage = 10;

            if (requestedPage < 1)
            {
                return(BadRequest($"{nameof(requestedPage)} must be at least 1."));
            }

            // Calculate Pages
            int lastPage = new EmployeeSC().CalculateLastPage(elementsPerPage);
            Pagination <EmployeePersonalInfoDTO> response = new(requestedPage, lastPage);

            if (lastPage == 0)
            {
                return(Ok(response));
            }

            // Get Selected Page
            IQueryable <Employee>          dbEmployees = new EmployeeSC().GetPage(elementsPerPage, (int)response.CurrentPage);
            List <EmployeePersonalInfoDTO> employees   = BaseSC.MaterializeIQueryable <Employee, EmployeePersonalInfoDTO>(dbEmployees);

            // Attach elements of the page to the response
            response.ResponseList = employees;

            return(Ok(response));
        }
        public IActionResult GetAll()
        {
            IQueryable <Customer> dbCustomers = new CustomerSC().GetAllCustomers();

            List <CustomerContactInfoDTO> customers = BaseSC.MaterializeIQueryable <Customer, CustomerContactInfoDTO>(dbCustomers);

            return(Ok(customers));
        }
        public IActionResult GetAll()
        {
            IQueryable <Employee> dbEmployees = new EmployeeSC().GetAllEmployees();

            List <EmployeePersonalInfoDTO> employees = BaseSC.MaterializeIQueryable <Employee, EmployeePersonalInfoDTO>(dbEmployees);

            return(Ok(employees));
        }
Exemplo n.º 6
0
        public IActionResult GetAll()
        {
            IQueryable <Product> dbProducts = new ProductSC().GetAllProducts();

            List <ProductBasicInfoDTO> products = BaseSC.MaterializeIQueryable <Product, ProductBasicInfoDTO>(dbProducts);

            return(Ok(products));
        }
Exemplo n.º 7
0
        public IActionResult GetAll()
        {
            // Se obtienen todos los registros.
            IQueryable <Employee> dbEmployees = new EmployeeSC().GetAllEmployees();

            // Se materialzian.
            List <EmployeePersonalInfoDTO> employees = BaseSC
                                                       .MaterializeIQueryable <Employee, EmployeePersonalInfoDTO>(dbEmployees);

            return(Ok(employees));
        }
Exemplo n.º 8
0
        public IActionResult GetAll()
        {
            // Se obtienen todos los registros.
            IQueryable <Product> dbProducts = new ProductSC().GetAllProducts();

            // Se materialzian.
            List <ProductBasicInfoDTO> products = BaseSC
                                                  .MaterializeIQueryable <Product, ProductBasicInfoDTO>(dbProducts);

            return(Ok(products));
        }
Exemplo n.º 9
0
        public IActionResult GetAll()
        {
            // Se obtienen todos los registros.
            IQueryable <Customer> dbCustomers = new CustomerSC().GetAllCustomers();

            // Se materialzian.
            List <CustomerContactInfoDTO> customers = BaseSC
                                                      .MaterializeIQueryable <Customer, CustomerContactInfoDTO>(dbCustomers);

            return(Ok(customers));
        }