I already have a city parameter which represent a cityname that I'll search on my DB, everything work well when I do mysite/List?city=mycityname, but what I'm trying to do is that I would also like to do a search by firstname combined with the cityname example List?city=mycityname&firstName=myfirstname. How can I do this ? Here is my query for city, I also added the firstname parameter but I don't really know how to add it so it'll filter both.
public string CurrentFirstName { get; set; }
public ViewResult List(string city, string firstName, int page = 1)
{
UsersListViewModel model = new UsersListViewModel
{
Users = repository.Userss
.Where(p =>city == null || p.CityName == city )
.OrderBy(p => p.UsersId)
.Skip((page - 1) * PageSize)
.Take(PageSize),
PagingInfo = new PagingInfo
{
CurrentPage = page,
UsersPerPage = PageSize,
TotalUsers = repository.Userss.Count()
},
CurrentCity = city
// CurrentFirstName = firstName
};
return View(model);
}