I want the user to be able to choose among some check boxes when I create a new asp.net identity users and save the result. I also want to get the value for each checkbox for each user. Each checkbox is an area (e.g London).
I have a table Area
ID | Name
Together with the applicationUser I guess I need a third table with many to many
Area.cs
public class Area
{
[Key]
public int ID { get; set; }
public string Area { get; set; }
public virtual ICollection<ApplicationUser> Users { get; set; }
}
IdentityModels.cs
public class ApplicationUser : IdentityUser
{
public virtual ICollection<Area> Areas { get; set; }
}
This gives me a third table ApplicationUsersAreas
I have added this to the view Account/Register.cshtml
<input type="checkbox" name="myarea" value="1" />
<input type="checkbox" name="myarea" value="2" />
<input type="checkbox" name="myarea" value="3" />
<input type="checkbox" name="myarea" value="4" />
How do I save the checkbox result for the user and how do I get the result for the user? E.g I want to save that the user checked the checkbox London and Denmark.
Aucun commentaire:
Enregistrer un commentaire