public static Participant ToEntity(this ParticipantModel model) { var participant = new Participant( ParticipantId.FromGuid(model.Id), UserId.FromGuid(model.UserId), PlayerId.Parse(model.PlayerId), new DateTimeProvider(model.RegisteredAt)); if (model.SynchronizedAt.HasValue && model.Matches != null) { participant.Snapshot(model.Matches.Select(match => match.ToEntity()), new DateTimeProvider(model.SynchronizedAt.Value)); } participant.ClearDomainEvents(); return(participant); }