I have this code that:
When you edit the UserProfile (with the corresponding CRUD (Controlers + Views)) you’ll see a dropdown for the SexType (that you can also edit with some other CRUD) and will correspond to a SexType table.
public class UserProfile{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public int SexTypeId { get; set; }
public virtual SexType SexType { get; set; }
public class SexType
{
public int SexTypeId { get; set; }
public string SexTypeDescription { get; set; }
public virtual ICollection<UserProfile> UserProfiles { get; set; }
}
public class UserProfileDBContext : DbContext //This creates the database according to the model
{
public DbSet<UserProfile> UserProfiles { get; set; }
public DbSet<SexType> SexType { get; set; }
}
What I want:
I want a simpler thing but I can’t manage to do it:
I want the sextype to be hardcoded (male / female) on my model (or in the controller).
Not in a database.
I don’t want any database but just visualize a dropdown with the “male/female” option every time I create or update records on “UserProfile”.
Can you help me with that?
You can do this in your view: