public async Task <QueryResult <LetterRequests> > GetLetterRequests(LetterRequestsQuery queryObj)
        {
            var result = new QueryResult <LetterRequests>();
            var query  = GetQueryable();

            query = ApplyFiltering(query, queryObj);
            var columnsMap = new Dictionary <string, Expression <Func <LetterRequests, object> > >()
            {
                ["status"]       = letterRequest => letterRequest.Status,
                ["urgency"]      = letterRequest => letterRequest.Urgency,
                ["employeeName"] = letterRequest => letterRequest.EmployeeName,
                ["type"]         = letterRequest => letterRequest.LetterType.Type,
                ["date"]         = letterRequest => letterRequest.DateCreated,
                ["userId"]       = letterRequest => letterRequest.UserId,
            };

            query             = _queryableExtensions.ApplyOrderingColumnMap(query, queryObj, columnsMap);
            result.TotalItems = await query.CountAsync();

            query        = _queryableExtensions.ApplyPaging(query, queryObj);
            result.Items = await query.ToListAsync();

            return(result);
        }
        private IQueryable <LetterRequests> ApplyFiltering(IQueryable <LetterRequests> query, LetterRequestsQuery queryObj)
        {
            // Wild search
            if (!string.IsNullOrWhiteSpace(queryObj.Search))
            {
                query = query.Where(a => a.DateCreated.ToString().Contains(queryObj.Search) ||
                                    a.EmployeeName.Contains(queryObj.Search) ||
                                    a.Status.Contains(queryObj.Search) ||
                                    a.Urgency.Contains(queryObj.Search) ||
                                    a.LetterType.Type.Contains(queryObj.Search) ||
                                    a.UserId.ToString().Contains(queryObj.Search));
            }

            if (!string.IsNullOrWhiteSpace(queryObj.Status))
            {
                query = query.Where(v => v.Status.Contains(queryObj.Status));
            }

            if (!string.IsNullOrWhiteSpace(queryObj.LetterType))
            {
                query = query.Where(v => v.LetterType.Type.Contains(queryObj.LetterType));
            }

            if (queryObj.UserId.HasValue)
            {
                query = query.Where(v => v.UserId.Equals(queryObj.UserId.Value));
            }

            return(query);
        }
        public async Task <ActionResult> GetLetterRequests([FromQuery] LetterRequestsQuery queryObj)
        {
            var queryResult = await _letterRequestService.GetLetterRequests(queryObj);

            return(Ok(queryResult));
        }