I have added a TeamID
to the AspNetUsers
table. There is a Teams table and every team is giving an ID. I want users to select a Team and when they are selected the TeamID
in the AspNetUsers
table to be updated using an action link to do this.
[HttpPost]
public ActionResult Select(int? id)
{
Team team = db.Teams.Find(id);
if (team != null)
{
ViewBag.RowsAffected = db.Database.ExecuteSqlCommand("UPDATE AspNetUsers SET TeamID = {0}", team);
}
return View();
}
This is the code I have tried but it does not work any suggestions or better ways to do it?