I am developing my first project in ASP.NET MVC and I want to improve, what I already done. I have web application with identity authorization, so every user can login using his own credentials.
I have done event/applicationuser model
, controller a views, so I can display, modify or delete events as well as users.
What I want to do is, that every user should have option to choose one or more events and sign up for selected event. As well as user should be able to see all his events after successful log in.
So I have to create new model for communicate between user and event. The problem is, that user inherits by IdentityDbContext
and event by DbContext
. Does anyone know some simple way to solve my problem?
This is my code:
1, ApplicationUser
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
2, Event model
public class Event
{
public int ID { get; set; }
public string Name { get; set; }
public DateTime? EventDate { get; set; }
public string EventLocation { get; set; }
public string Description { get; set; }
}
3, Event context
public class Context:DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
public DbSet<Event> Event { get; set; }
4, Model EventParticipant to communicate between user and event - not working
public class EventParticipant
{
public int ID { get; set; }
public string ApplicationUserID { get; set; }
public bool Status { get; set; }
public ApplicationUser ApplicationUser { get; set; }
public virtual ICollection<Event> Event { get; set; }
}