Пример #1
0
        public PagedResultModel <Client> Get(int pageIndex, int pageSize)
        {
            if (pageIndex < 0)
            {
                throw new ArgumentOutOfRangeException("pageIndex", "pageIndex no debe ser menor a cero.");
            }
            if (pageSize < 0)
            {
                throw new ArgumentOutOfRangeException("pageSize", "pageIndex no debe ser menor a cero.");
            }

            var totalItems = clientsRepository.TotalClients();
            var totalPages = (long)Math.Floor((decimal)totalItems / pageSize);
            var items      = clientsRepository.Get(pageIndex, pageSize);

            var result = new PagedResultModel <Client>
            {
                PageIndex  = pageIndex,
                PageSize   = pageSize,
                TotalPages = totalPages,
                TotalItems = totalItems,
                Items      = items
            };

            return(result);
        }
Пример #2
0
        public async Task <IActionResult> GetClient(Guid id)
        {
            Client result = await _clientRepository.Get(id);

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound());
        }
Пример #3
0
        public Task <ClientsModel> GetAsync(int id)
        {
            var dal = _clientRepository.Get(id);

            if (dal == null)
            {
                return(Task.FromResult <ClientsModel>(null));
            }
            else
            {
                ClientsModel model = AutoMapperGenericHelper <Clients, ClientsModel> .Convert(dal);

                return(Task.FromResult(model));
            }
        }
Пример #4
0
 public IEnumerable <Clients> Get()
 {
     return(_clientsRepository.Get());
 }