public async Task <PaggedList <Message> > GetMessagesForUser(MessageParams messageParams)
        {
            var messages = _context.Messages
                           .Include(m => m.Sender).ThenInclude(u => u.Photos)
                           .Include(m => m.Recipient).ThenInclude(u => u.Photos)
                           .AsQueryable();

            switch (messageParams.MessageContainer)
            {
            case "Inbox":
                messages = messages.Where(u => u.RecipientId == messageParams.UserId && u.RecipientDeleted == false);
                break;

            case "Outbox":
                messages = messages.Where(u => u.SenderId == messageParams.UserId && u.SenderDeleted == false);
                break;

            default:
                messages = messages.Where(u => u.RecipientId == messageParams.UserId && u.RecipientDeleted == false && u.IsRead == false);
                break;
            }

            messages = messages.OrderByDescending(m => m.MessageSent);

            return(await PaggedList <Message> .CreateAsync(messages, messageParams.PageNumber, messageParams.PageSize));
        }
        public async Task <PaggedList <User> > GetUsers(UserParams userParams)
        {
            var users = _context.Users.Include(p => p.Photos)
                        .OrderByDescending(u => u.LastActive).AsQueryable();

            users = users.Where(u => u.Id != userParams.UserId);

            users = users.Where(u => u.Gender == userParams.Gender);

            if (userParams.MinAge != 18 || userParams.MaxAge != 99)
            {
                var minDob = DateTime.Today.AddYears(-userParams.MaxAge - 1);
                var maxDob = DateTime.Today.AddYears(-userParams.MinAge);

                users = users.Where(u => u.DateOfBirth >= minDob && u.DateOfBirth <= maxDob);
            }

            if (!string.IsNullOrEmpty(userParams.OrderBy))
            {
                switch (userParams.OrderBy)
                {
                case "created":
                    users = users.OrderByDescending(u => u.Created);
                    break;

                default:
                    users = users.OrderByDescending(u => u.LastActive);
                    break;
                }
            }

            return(await PaggedList <User> .CreateAsync(users, userParams.PageNumber, userParams.PageSize));
        }