Front-end
- async getFilterData() {
- this.setState({ tableLoading: true });
- const TitleFIlter = document.getElementById("TitleFIlter").value
- const descriptionFilter = document.getElementById("DescriptionFilter").value
- const priceminFIlter = document.getElementById("PriceMin").value
- const pricemaxFIlter = document.getElementById("PriceMax").value
- console.log(" title =" + TitleFIlter);
- console.log("description = " + descriptionFilter);
- console.log(" PriceMin =" + priceminFIlter);
- console.log("PriceMax = " + pricemaxFIlter);
- const url = `api/upload/${TitleFIlter}/${descriptionFilter}/${priceminFIlter}/${pricemaxFIlter}`
- const response = await axios.get(url)
- const data = await response.data;
- this.setState({
- allproducts: data,
- tableLoading: false
- });
- console.log(data);
- }
- HttpGet]
- [Route("{Title?}/{Description?}/{Pricemin?}/{Pricemax?}")]
- public async Task
- > GetFilter([FromQuery]
- string Title,
- string Description,
- int PriceMin,
- int PriceMax
- )
- {
- IQueryable
products = _context.products; - if (!string.IsNullOrEmpty(Title))
- products = products.Where(x => x.Title.ToLower().Contains(Title.ToLower()));
- if (!string.IsNullOrEmpty(Description))
- products = products.Where(x => x.Description.ToLower().Contains(Description.ToLower()));
- if (PriceMin > 0)
- products = products.Where(x => x.Price >= PriceMin);
- if (PriceMax > 0)
- products = products.Where(x => x.Price <= PriceMax);
- return await products.ToListAsync();
- }
How do i solve this
osyris zosarPosted Jun 4, 2021, 1:46 PM
I have chance the url in the front-end to:
entire reactjs (frontend- code):
I think im doing something wrong in the frond-end but im not sure what.
please help me out.
Sachin SinghPosted Jun 2, 2021, 7:42 PM
> GetFilter([FromQuery]
osyris zosarPosted Jun 2, 2021, 4:54 PM
Jishan SiddiquePosted Jun 2, 2021, 4:41 PM