public static CaseFileAggregate New(List <DomainEvent> evts)
        {
            var result = new CaseFileAggregate();

            foreach (var evt in evts)
            {
                result.Handle(evt);
            }

            return(result);
        }
        public static CaseFileAggregate New(string name, string description, int version, string owner, string payload = null, string fileId = null)
        {
            var result = new CaseFileAggregate();

            lock (result.DomainEvents)
            {
                if (string.IsNullOrWhiteSpace(fileId))
                {
                    fileId = Guid.NewGuid().ToString();
                }

                var evt = new CaseFileAddedEvent(Guid.NewGuid().ToString(), BuildCaseFileIdentifier(fileId, version), version, fileId, name, description, DateTime.UtcNow, owner, payload);
                result.Handle(evt);
                result.DomainEvents.Add(evt);
            }

            return(result);
        }