Madhav Sharma

Madhav Sharma

  • 818
  • 892
  • 36.5k

Need search during infinite loading of data

Dec 23 2019 2:09 AM
I need help, 
Here the problem is that I want to make an API for the app, during scroll I can search the data. In the below code, I am able to do Infinite scroll but not sure how to give search functionality. For example, I have a scroll 3 pages (1 page have 10 records) and during that time I want to search string like "David" so it will give search string within 30 records
 
public dynamic GetAllUsersList(int Count, int UserId)
{
using (LystenEntities db = new LystenEntities())
{
OnlineUserViewModel uv = new OnlineUserViewModel();
uv.TotalCount = db.User_Master.Where(x => x.IsActive == true).Where(x => x.RoleId != 1 && x.Id != UserId).ToList().Count();
int skip = 10 * Count;
string baseURL = HttpContext.Current.Request.Url.Authority;
baseURL += (WebConfigurationManager.AppSettings["userimagepath"]).Replace("~", "");
uv.userdetail =
db.User_Master.Where(x => x.RoleId != 1 && x.Id != UserId && x.IsActive == true).Select(x => new userdetail()
{
Id = x.Id,
Email = x.Email,
Displayname = x.FullName == null ? "" : x.FullName,
Image = (x.Image == null) ? "" : x.Image == "" ? "" : (baseURL + x.Image)
}).OrderBy(x => x.Displayname).Skip(skip).Take(10).ToList();
return uv;
}
}
 

Answers (1)