I am using ASP.NET MVC Entity Framework and I created an API controller, now I want to add a method that is basically a copy of the put method, however I want to adjust this method so it updates a single column
[ResponseType(typeof(void))]
[Authorize]
public IHttpActionResult PutUser(int id, Users user)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != user.id)
{
return BadRequest();
}
db.Entry(user).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!UsersExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return StatusCode(HttpStatusCode.NoContent);
}
each user in my User class has an email and column called isOnline, for this method I want to update the isOnline to true based on the email.
The examples I have seen online are for non API controllers. Please Help!