public RegionsViewModel(int page, int pageSize, IEnumerable <RegionDTO> regions, string regionName, bool isAdmin) { if (regionName == null) { Regions = regions.Skip((page - 1) * pageSize).Take(pageSize); Total = regions.Count(); CanCreate = isAdmin; } else { Regions = from region in regions where region.RegionName.ToLower().Contains(regionName.ToLower()) select region; Total = Regions.Count(); CanCreate = isAdmin; } }