Changed the method for all the filters to stomething more standardized and .net compliant (also easier built into openapi v3)
This commit is contained in:
@@ -20,21 +20,21 @@ namespace ScrumTaskboard.Controllers
|
||||
|
||||
// GET: api/category
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumCategory>>> GetCategory()
|
||||
public async Task<ActionResult<IEnumerable<ScrumCategory>>> GetCategory([FromQuery]string? title, [FromQuery]int? projectid, [FromQuery] string? color)
|
||||
{
|
||||
var filtered = _context.Categories.AsQueryable();
|
||||
|
||||
if (HttpContext.Request.Query["title"].ToString() != "")
|
||||
if (title != null)
|
||||
{
|
||||
filtered = filtered.Where<ScrumCategory>(c => c.title.Contains(HttpContext.Request.Query["title"].ToString()));
|
||||
filtered = filtered.Where<ScrumCategory>(c => c.title.Contains(title));
|
||||
}
|
||||
if (Convert.ToInt32(HttpContext.Request.Query["projectid"]) != 0)
|
||||
if (projectid != null)
|
||||
{
|
||||
filtered = filtered.Where<ScrumCategory>(c => c.projectid == Convert.ToInt32(HttpContext.Request.Query["projectid"]));
|
||||
filtered = filtered.Where<ScrumCategory>(c => c.projectid == projectid);
|
||||
}
|
||||
if (HttpContext.Request.Query["color"].ToString() != "")
|
||||
if (color != null)
|
||||
{
|
||||
filtered = filtered.Where<ScrumCategory>(c => c.color == HttpContext.Request.Query["color"].ToString());
|
||||
filtered = filtered.Where<ScrumCategory>(c => c.color == color);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user