Ejemplo n.º 1
0
        public static CaseWorkerTaskAggregate New(CaseInstanceWorkerTaskAddedEvent evt)
        {
            var result = new CaseWorkerTaskAggregate
            {
                CasePlanInstanceId        = evt.AggregateId,
                CasePlanInstanceElementId = evt.CasePlanInstanceElementId,
                CreateDateTime            = DateTime.UtcNow,
                UpdateDateTime            = DateTime.UtcNow,
                Version     = 0,
                AggregateId = BuildCaseWorkerTaskIdentifier(evt.AggregateId, evt.CasePlanInstanceElementId)
            };

            return(result);
        }
Ejemplo n.º 2
0
        public bool TryAddWorkerTask(string casePlanInstanceElementId)
        {
            var workerTask = WorkerTasks.FirstOrDefault(_ => _.CasePlanElementInstanceId == casePlanInstanceElementId);

            if (workerTask != null)
            {
                return(false);
            }

            var evt = new CaseInstanceWorkerTaskAddedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, casePlanInstanceElementId, DateTime.UtcNow, CaseOwnerRole);

            Handle(evt);
            DomainEvents.Add(evt);
            return(true);
        }
Ejemplo n.º 3
0
        private void Handle(CaseInstanceWorkerTaskAddedEvent evt)
        {
            var child = GetCasePlanItem(evt.CasePlanInstanceElementId);

            if (child == null)
            {
                throw new AggregateValidationException(new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("validation", $"unknown child '{evt.CasePlanInstanceElementId}'")
                });
            }

            WorkerTasks.Add(new CasePlanInstanceWorkerTask
            {
                CasePlanElementInstanceId = evt.CasePlanInstanceElementId,
                CreateDateTime            = evt.CreateDateTime
            });
            UpdateDateTime = evt.CreateDateTime;
            Version        = evt.Version;
        }
        public static CaseWorkerTaskAggregate New(CaseInstanceWorkerTaskAddedEvent evt)
        {
            var result = new CaseWorkerTaskAggregate
            {
                CasePlanInstanceId        = evt.AggregateId,
                CasePlanInstanceElementId = evt.CasePlanInstanceElementId,
                CreateDateTime            = DateTime.UtcNow,
                UpdateDateTime            = DateTime.UtcNow,
                Roles = evt.CaseOwnerRole == null ? new List <CaseWorkerTaskRole>() : new List <CaseWorkerTaskRole>
                {
                    new CaseWorkerTaskRole
                    {
                        Claims = evt.CaseOwnerRole.Claims,
                        RoleId = evt.CaseOwnerRole.Id
                    }
                },
                Version     = 0,
                AggregateId = BuildCaseWorkerTaskIdentifier(evt.AggregateId, evt.CasePlanInstanceElementId)
            };

            return(result);
        }