So I am working on this project where I have to do CRUD operations and I am stuck at getting the user by their id.
This is my function where I get all the users, and I didn't use Entity Framework here. This one works perfectly.
[Route("AllOperators")]
public DataSet GetAllOperators()
{
DataSet ds = dbLayer.MyValues();
return ds;
}
And this is what I have tried to achieve getting a user by his id.
[HttpGet]
[Route("api/data/GetById")]
public IHttpActionResult GetById(string id)
{
var result = sl3.Operator.Where(x => x.id == id).FirstOrDefault();
if (id == null) return NotFound();
else return result;
}
Here I used Entity Framework as someone suggested me but I'm getting an error at the end where I return result
and it says that
cannot implicitly convert type 'WebApp.Models.Operator' to 'system.web.http.ihttpactionresult'
Can someone please help me fix this bug or even suggest me another way I can get the desired user by his id?