public void SaveParticipant(UserEvent participant)
{
if (DeadlineForEventHasPassed(participant.EventId))
{
throw new ArgumentException("You cant create or edit a participation after the deadline");
}
if (context.UserEvents.Where(x => x.EventId == participant.EventId && x.UserEmail.Equals(participant.UserEmail)).Count() == 0)
{
context.AddToUserEvents(participant);
}
else
{
context.UpdateDetachedEntity<UserEvent>(participant, x => x.EventId);
}
context.SaveChanges();
}