public async Task <IActionResult> Index(
            [FromQuery] ActivityQueryModel query)
        {
            ViewBag.currentFirstNameParam    = query.FirstName;
            ViewBag.currentLastNameParam     = query.LastName;
            ViewBag.currentFromDateParam     = query.FromDate;
            ViewBag.currentToDateParam       = query.ToDate;
            ViewBag.currentActivityTypeParam = (int)query.ActivityType;

            var result = await _activityServices.List(query);

            return(View(result));
        }
        public async Task <PagedResultModel <ActivityViewModel> > List(ActivityQueryModel query)
        {
            int skip = (query.Page - 1) * query.Limit;

            var queryable = _context.Activities.AsQueryable();

            if (!string.IsNullOrEmpty(query.FirstName))
            {
                queryable = queryable.Where(x => x.FirstName.Contains(query.FirstName));
            }

            if (!string.IsNullOrEmpty(query.LastName))
            {
                queryable = queryable.Where(x => x.LastName.Contains(query.LastName));
            }

            if (query.ActivityType != 0)
            {
                queryable = queryable.Where(x => x.ActivityType == query.ActivityType);
            }

            if (query.FromDate != null)
            {
                queryable = queryable.Where(x => x.CreatedAt >= query.FromDate);
            }

            if (query.ToDate != null)
            {
                queryable = queryable.Where(x => x.CreatedAt <= query.ToDate);
            }

            var activities = await queryable
                             .OrderByDescending(x => x.CreatedAt)
                             .Skip(skip)
                             .Take(query.Limit)
                             .ToListAsync();

            int totalActivities = await queryable.CountAsync();

            int totalPage = (int)Math.Ceiling((double)totalActivities / query.Limit);

            return(new PagedResultModel <ActivityViewModel>
            {
                PageSize = query.Limit,
                CurrentPage = query.Page,
                Data = _mapper.Map <List <ActivityViewModel> >(activities),
                TotalPage = totalPage,
                TotalRecord = totalActivities
            });
        }