예제 #1
0
        public async Task <IActionResult> Clients(int?page, string search)
        {
            ViewBag.Search = search;
            ClientsDto clients = await _clientService.GetClientsAsync(search, page ?? 1);

            if (!await _authorization.IsAdmin(User))
            {
                clients = await _clientManagerService.GetManagedClients(User.GetSubjectId(), search, page ?? 1, 10);
            }
            return(View(clients));
        }
예제 #2
0
        public async Task <ActionResult <ClientsApiDto> > Get(string searchText, int page = 1, int pageSize = 10)
        {
            ClientsApiDto clientsApiDto;

            if (!await _authorization.IsAdmin(User))
            {
                var pagedList =
                    await _clientManagerService.GetManagedClients(User.GetSubjectId(), searchText, page, pageSize);

                clientsApiDto = pagedList.ToClientApiModel <ClientsApiDto>();
            }
            else
            {
                var clientsDto = await _clientService.GetClientsAsync(searchText, page, pageSize);

                clientsApiDto = clientsDto.ToClientApiModel <ClientsApiDto>();
            }

            return(Ok(clientsApiDto));
        }