public Task <ClientPaginatedList> GetPaginatedList(ClientListQuery query)
        {
            var paginatedList = new ClientPaginatedList();
            var queryable     = _context.Clients.AsQueryable();

            if (!string.IsNullOrEmpty(query.SearchText))
            {
                queryable.Where(x => x.ClientName.Contains(query.SearchText));
            }
            if (!string.IsNullOrEmpty(query.SortBy))
            {
                var camelCase    = Char.ToUpper(query.SortBy[0]) + query.SortBy.Substring(1);
                var propertyInfo = typeof(ClientListItem).GetProperty(camelCase);
                if (query.Descending)
                {
                    queryable.OrderBy(x => propertyInfo.GetValue(x, null));
                }
                else
                {
                    queryable.OrderByDescending(x => propertyInfo.GetValue(x, null));
                }
            }

            paginatedList.Data = queryable
                                 .Skip((query.Page - 1) * query.RowsPerPage)
                                 .Take(query.RowsPerPage)
                                 .Select(x => _mapper.Map <ClientListItem>(x))
                                 .ToList();
            paginatedList.TotalRecords = queryable.Count();
            return(Task.FromResult(paginatedList));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            ClientListQuery clientListQuery = new ClientListQuery();

            clientListQuery.Clients = _clientQueryRepository.GetAll();
            return(View(clientListQuery));
        }
Ejemplo n.º 3
0
 public ClientService(ClientRepository clientRepository, ClientAccordingToEmailQuery clientAccordingToEmailQuery,
                      ClientListQuery clientListQuery, SonglistListQuery songlistListQuery, SonglistRepository songlistRepository,
                      UserAccountRepository userRepository)
 {
     this.clientRepository            = clientRepository;
     this.clientAccordingToEmailQuery = clientAccordingToEmailQuery;
     this.clientListQuery             = clientListQuery;
     this.songlistRepository          = songlistRepository;
     this.songlistListQuery           = songlistListQuery;
     this.userRepository = userRepository;
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> Get([FromQuery] ClientListQuery query)
        {
            var model = await this._mediator.Send(query);

            return(this.Ok(model));
        }