public IActionResult Get([FromQuery] string sort, [FromQuery] string filter, [FromQuery] string value) { if (!String.IsNullOrEmpty(filter)) { if (String.IsNullOrEmpty(value)) { return(BadRequest("Parameterless searches have been disabled")); } var consultantDtos = new List <ConsultantDto>(); IEnumerable <Consultant> consultantsFromDb = new List <Consultant>(); if (filter == "firstname") { consultantsFromDb = consultantService.GetByfirstName(value); } else { consultantsFromDb = consultantService.GetByLastname(value); } foreach (var c in consultantsFromDb) { consultantDtos.Add(new ConsultantDto { FirstName = c.Firstname, LastName = c.Lastname, Email = c.Email, WorkEmail = c.WorkEmail, Telephone = c.Telephone, Mobile = c.Mobile, Straat = c.Address.Straat, Number = c.Address.Number, Country = c.Address.Country, Zipcode = c.Address.Zipcode }); } return(Ok(consultantDtos)); } var consultants = consultantService.GetAll(); return(Ok(consultants)); }