public ActionResult <IEnumerable <User> > Get([FromQuery] FilterVehiclesPriceList filter) { try { return(Ok(_userService.GetAllUsers(filter))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public FilteredData <User> ReadAll(FilterVehiclesPriceList filter) { //Create a Filtered List var FilteredData = new FilteredData <User>(); //If there is a Filter then filter the list and set Count //if (filter != null && filter.ItemsPrPage > 0 && filter.CurrentPage > 0) //{ // FilteredData.Items = _ctx.Users // .Select(u => new User { Id = u.Id, Email = u.Email}) // .Skip((filter.CurrentPage - 1) * filter.ItemsPrPage) // .Take(filter.ItemsPrPage); // //FilteredData.Count = _ctx.Users.Count(); // return FilteredData; //} //Else just return the full list and get the count from the list (to save a SQL call) FilteredData.Items = _ctx.Users .Select(u => new User { Id = u.Id, Email = u.Email }); //FilteredData.Count = FilteredData.Items.Count(); return(FilteredData); }
public static IQueryable <VehiclePriceListItem> BuildFilteredOptions(this IQueryable <VehiclePriceListItem> query, FilterVehiclesPriceList filter) { query = filter.MenufacturerID != null?query.Where(vpli => vpli.VehicleMenufacturerId == filter.MenufacturerID) : query; query = filter.MenufacturingOriginID != null?query.Where(vpli => vpli.VehicleMenufacturingOriginId == filter.MenufacturingOriginID) : query; query = filter.VehicleTypeID != null?query.Where(vpli => vpli.VehicleTypeId == filter.VehicleTypeID) : query; query = filter.PriceRange != null?query.Where(vpli => (int.Parse(vpli.AskingPrice) >= filter.PriceRange.LowPrice) && (int.Parse(vpli.AskingPrice) <= filter.PriceRange.TopPrice)) : query; return(query); }
public FilteredData <User> GetAllUsers(FilterVehiclesPriceList filter = null) { return(_userRepo.ReadAll(filter)); }