public async Task <IActionResult> Get(DataTableParameterDto parameters)
        {
            // Query Base
            var query = from t in _context.Tasks
                        join p in _context.Projects on t.ProjectId equals p.Id
                        select new
            {
                t.Id,
                Project = p.Title,
                t.Done,
                t.Description,
                t.Title,
            };

            // Global Filter
            if (!string.IsNullOrEmpty(parameters.GlobalFilter))
            {
                query = query.Where(m =>
                                    EF.Functions.Like(m.Title, $"%{parameters.GlobalFilter}%") ||
                                    EF.Functions.Like(m.Description, $"%{parameters.GlobalFilter}%"));
            }

            // Recourd Count
            var recordCount = await query.CountAsync();

            // Paginate
            var tasks = await query.Paginate(parameters.Page, parameters.Take).ToListAsync();

            return(Ok(new PaginateDto
            {
                Total = recordCount,
                Page = parameters.Page,
                Records = tasks.ToList()
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> Get(DataTableParameterDto parameters)
        {
            // Query Base
            var query = from t in _context.Projects
                        select new
            {
                t.Id,
                t.Active,
                t.Type,
                t.Description,
                t.Title,
            };

            // Global Filter
            if (!string.IsNullOrEmpty(parameters.GlobalFilter))
            {
                query = query.Where(m =>
                                    EF.Functions.Like(m.Title, $"%{parameters.GlobalFilter}%") ||
                                    EF.Functions.Like(m.Description, $"%{parameters.GlobalFilter}%"));
            }

            var recordCount = await query.CountAsync();

            // Pagination
            var projects = await query.Paginate(parameters.Page, parameters.Take)
                           .ToListAsync();

            return(Ok(new PaginateDto()
            {
                Page = parameters.Page,
                Total = recordCount,
                Records = projects
            }));
        }