CapRaffle.Domain.Implementation.EventRepository.SaveParticipant C# (CSharp) Method

SaveParticipant() public method

public SaveParticipant ( UserEvent participant ) : void
participant CapRaffle.Domain.Model.UserEvent
return void
        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();
        }