Ejemplo n.º 1
0
 public EitherAsync <Error, Unit> Handle(Request request)
 {
     DomainEvents.Add(new SampleEvent {
         Data = "SampleHandler invoked"
     });
     return(Unit.Default);
 }
        /// <summary>
        /// 注销卡(只能注销已经绑定过的卡类型)
        /// </summary>
        /// <param name="cardType"></param>
        /// <param name="reason"></param>
        public void CancellationCard(string cardType, string reason)
        {
            var card = GetCard(cardType);

            Cards.Remove(card);
            DomainEvents.Add(new OnCardChanged(card, CardOperationType.CancellationCard, reason));
        }
Ejemplo n.º 3
0
        public void AcceptAgreement(DeliveryMode delivery, ProfileKind acceptedByKind)
        {
            if (Status != AgreementStatus.WaitingForProducerApproval &&
                Status != AgreementStatus.WaitingForStoreApproval)
            {
                throw SheaftException.Validation("Le partenariat ne peut pas être accepté, il n'est en attente d'acceptation.");
            }

            if (Status == AgreementStatus.WaitingForProducerApproval && acceptedByKind != ProfileKind.Producer)
            {
                throw SheaftException.Validation("Le partenariat doit être accepté par le producteur.");
            }

            if (Status == AgreementStatus.WaitingForStoreApproval && acceptedByKind != ProfileKind.Store)
            {
                throw SheaftException.Validation("Le partenariat doit être accepté par le magasin.");
            }

            if (delivery != null)
            {
                ChangeDelivery(delivery);
            }

            if (!DeliveryModeId.HasValue)
            {
                throw SheaftException.Validation("Le partenariat doit avoir un mode de livraison rattaché.");
            }

            Store.IncreaseProducersCount();

            Status = AgreementStatus.Accepted;
            DomainEvents.Add(new AgreementAcceptedEvent(Id, acceptedByKind));
        }
            public EitherAsync <Error, Unit> Handle(Request request)
            {
                var player = _repo.Get(_currentUser.Tenant, request.PlayerId);

                var result = player
                             .Map(p =>
                {
                    p.ChangeName(request.FirstName, request.LastName);
                    return(_repo.Update(p, request.EntityVersion));
                })
                             .MatchAsync(
                    RightAsync: async right => await right.ToEither(),
                    Left: l => l)
                             .ToAsync()
                             .Do(p => DomainEvents.Add(new PlayerNameCorrected
                {
                    TenantId  = p.Tenant,
                    PlayerId  = p.Id,
                    Version   = p.Version,
                    FirstName = p.FirstName,
                    LastName  = p.LastName
                }))
                             .Map(p => Unit.Default);

                return(result);
            }
Ejemplo n.º 5
0
        public void SetCompleted(List <SubItem> items)
        {
            if (items.Count == 0)
            {
                Completed = false;
                DomainEvents.Add(new TodoListItemCompletedStateChanged {
                    Item = this
                });
                return;
            }

            if (!items.All(item => item.ListItemId == Id))
            {
                return;
            }

            var itemsCompleted = items.All(item => item.Completed);

            if (Completed && !itemsCompleted)
            {
                Completed = false;
                DomainEvents.Add(new TodoListItemCompletedStateChanged {
                    Item = this
                });
            }
            else if (!Completed && itemsCompleted)
            {
                Completed = true;
                DomainEvents.Add(new TodoListItemCompletedStateChanged {
                    Item = this
                });
            }
        }
        public void UpdateMetadata(string flowNodeInstanceId, string key, string value)
        {
            var evt = new MetadataUpdatedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, flowNodeInstanceId, key, value, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
        private string TryAddExecutionPointer(string pathId, BaseFlowNode flowNode, ICollection <MessageToken> outcomeValues = null)
        {
            ICollection <MessageToken> incoming = new List <MessageToken>();

            if (outcomeValues != null)
            {
                incoming = outcomeValues;
            }

            var instanceId = string.Empty;

            if (!TryAddInstance(flowNode, pathId, out instanceId))
            {
                var pointer = GetActiveExecutionPointer(pathId, instanceId);
                if (pointer != null)
                {
                    var e = new IncomingTokenAddedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, pointer.ExecutionPathId, pointer.Id, JsonConvert.SerializeObject(incoming), DateTime.UtcNow);
                    Handle(e);
                    DomainEvents.Add(e);
                    return(pointer.Id);
                }
            }

            var id  = Guid.NewGuid().ToString();
            var evt = new ExecutionPointerAddedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, id, pathId, instanceId, flowNode.EltId, JsonConvert.SerializeObject(incoming), DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
            return(id);
        }
        public void UpdateState(FlowNodeInstance instance, ActivityStates state, string message = null)
        {
            var evt = new ActivityStateUpdatedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, instance.EltId, state, message, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
        public void AddFlowNodeDef(BaseFlowNode node)
        {
            var evt = new FlowNodeDefCreatedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, JsonConvert.SerializeObject(node), DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
        public void CompleteFlowNodeInstance(string id)
        {
            var evt = new FlowNodeInstanceCompletedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, id, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
        public void Start(string nameIdentifier)
        {
            var evt = new ProcessInstanceStartedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, nameIdentifier, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
Ejemplo n.º 12
0
        public void ModifyPlanning(Priority priority, Activity?activity)
        {
            Priority = priority;
            Activity = activity;

            DomainEvents.Add(new TaskPlanningModifiedEvent(priority, activity));
        }
Ejemplo n.º 13
0
        private void DrawACard()
        {
            firstDuelist.DrawCard();
            var duelistState = DuelistState.From(firstDuelist);

            DomainEvents.Add(new CardDrawed(id, duelistState.Id, duelistState.Hand.Last()));
        }
Ejemplo n.º 14
0
        public void SetStatus(OrderStatus status)
        {
            if (Status == OrderStatus.Refused || Status == OrderStatus.Confirmed)
            {
                return;
            }

            switch (status)
            {
            case OrderStatus.Waiting:
                ExpiredOn = null;
                break;

            case OrderStatus.Expired:
                ExpiredOn = DateTimeOffset.UtcNow;
                break;

            case OrderStatus.Validated:
                ExpiredOn = null;
                DomainEvents.Add(new OrderValidatedEvent(Id));
                break;

            case OrderStatus.Refused:
                ExpiredOn = null;
                break;

            case OrderStatus.Confirmed:
                ExpiredOn = null;
                DomainEvents.Add(new OrderConfirmedEvent(Id));
                break;
            }

            Status = status;
        }
Ejemplo n.º 15
0
        public void SetVariable(string key, string value)
        {
            var evt = new VariableUpdatedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, key, value, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
Ejemplo n.º 16
0
        public void UpdatePermission(string roleId, ICollection <KeyValuePair <string, string> > claims)
        {
            var evt = new CaseInstanceRoleUpdatedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, roleId, claims, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
Ejemplo n.º 17
0
        public Deskwork Complete()
        {
            EnsureActive();

            if (Completion != EWorkCompletion.未完成)
            {
                return(this);
            }

            if (Steps.Any(x => !x.Done))
            {
                throw new UserFriendlyException("请先完成所有子流程");
            }

            CompletionTime = Clock.Now;

            if (CreationTime.AddHours(TimeLimit) <= CompletionTime)
            {
                Completion = EWorkCompletion.时完成;
            }
            else
            {
                Completion = EWorkCompletion.超时完成;
            }

            foreach (var step in Steps)
            {
                step.Completion = Completion; // 工单流程的完成情况与工单一致
            }

            DomainEvents.Add(new WorkCompletionEventData());
            return(this);
        }
Ejemplo n.º 18
0
        public void UpdatePayload(string payload)
        {
            var evt = new ProcessFilePayloadUpdatedEvent(Guid.NewGuid().ToString(), AggregateId, Version, payload, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
Ejemplo n.º 19
0
 public virtual void PromoteTo(EmploymentRole role)
 {
     EmploymentRole = role;
     DomainEvents.Add(new EmployeeWasPromotedEvent {
         Employee = this
     });
 }
        public void Reject()
        {
            var evt = new AccountAccessConsentRejectedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
Ejemplo n.º 21
0
        public void Update(string name, string description)
        {
            var evt = new ProcessFileUpdatedEvent(Guid.NewGuid().ToString(), AggregateId, Version, name, description, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
        public void Confirm(IEnumerable <string> accountIds)
        {
            var evt = new AccountAccessConsentConfirmedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, accountIds, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
        }
Ejemplo n.º 23
0
        public void Update(PhoneNumber instance)
        {
            Value             = instance.Value;
            PhoneNumberTypeId = instance.PhoneNumberTypeId;

            DomainEvents.Add(new PersonPhoneNumberUpdatedEvent(this));
        }
Ejemplo n.º 24
0
        public void ModifyPlanning(Planning planning, Priority priority)
        {
            Priority = priority;
            Planning = planning;

            DomainEvents.Add(new FeaturePlanningModifiedEvent(planning, priority));
        }
Ejemplo n.º 25
0
 public void MakeLeft()
 {
     base.Role = Roles.Left;
     DomainEvents.Add(new ContributorLeft()
     {
         ListId = this.ListId, AccountId = this.AccountId
     });
 }
Ejemplo n.º 26
0
        public void AddDomainEvent(IDomainEvent domainEvent)
        {
            Guard.ArgumentNotNull(domainEvent, nameof(domainEvent));
            var record = new DomainEventRecord(domainEvent);

            DomainEvents.Add(record);
            _eventsToSave.Add(record);
        }
Ejemplo n.º 27
0
        public void Update(string name)
        {
            Name = name;

            var updateEvent = new $domainName$UpdatedEvent(Id, Name);

            DomainEvents.Add(updateEvent);
        }
Ejemplo n.º 28
0
 public void Invited()
 {
     base.Role = Roles.Invited;
     DomainEvents.Add(new InvitationSent()
     {
         ListId = this.ListId, InviteeAccountId = this.AccountId
     });
 }
Ejemplo n.º 29
0
        public TodoList(string title)
        {
            ListTitle = title;

            DomainEvents.Add(new TodoListCreated {
                List = this
            });
        }
Ejemplo n.º 30
0
        public void SpecifyUserStoryInfo(string description, string acceptanceCriteria, ValueArea valueArea)
        {
            Description        = description;
            AcceptanceCriteria = acceptanceCriteria;
            ValueArea          = valueArea;

            DomainEvents.Add(new UserStoryInfoModifiedEvent(description, acceptanceCriteria, valueArea));
        }