Exemple #1
0
        public async Task HandleAsync(IDomainEvent <Order, OrderId, OrderStartedDomainEvent> domainEvent, CancellationToken cancellationToken)
        {
            var buyerId = BuyerId.With(Guid.Parse(domainEvent.AggregateEvent.UserId));

            var b = await _aggregateStore
                    .LoadAsync <Buyer, BuyerId>(buyerId, CancellationToken.None)
                    .ConfigureAwait(false);

            var cardTypeId = (domainEvent.AggregateEvent.CardTypeId != 0) ? domainEvent.AggregateEvent.CardTypeId : 1;

            await _aggregateStore.UpdateAsync <Buyer, BuyerId>(buyerId, SourceId.New,
                                                               (buyer, c) => {
                if (buyer.IsNew)
                {
                    buyer.Create(domainEvent.AggregateEvent.UserId, domainEvent.AggregateEvent.UserName);
                }

                buyer.VerifyOrAddPaymentMethod(cardTypeId,
                                               $"Payment Method on {DateTime.UtcNow}",
                                               domainEvent.AggregateEvent.CardNumber,
                                               domainEvent.AggregateEvent.CardSecurityNumber,
                                               domainEvent.AggregateEvent.CardHolderName,
                                               domainEvent.AggregateEvent.CardExpiration,
                                               domainEvent.AggregateIdentity);
                return(Task.FromResult(0));
            }, CancellationToken.None
                                                               ).ConfigureAwait(false);

            var orderStatusChangedTosubmittedIntegrationEvent = new OrderStatusChangedToSubmittedIntegrationEvent(domainEvent.AggregateIdentity.Value, OrderStatus.Submitted.Name, "bob");
            await _endpoint.Publish(orderStatusChangedTosubmittedIntegrationEvent);
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (BuyerId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PrimaryPhone?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (SecondaryPhone?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Fax?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (WebSite?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Company?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AnnualTurnOver?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LegalRepresentative?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Rating?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CreditInsurance.GetHashCode());
            hashCode = hashCode * -1521134295 + (Logo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AddressOne?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AddressTwo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (VatNumber?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ContactPerson?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Prefix?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Temp?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (UserName?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PasswordHash?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (SecurityStamp?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (EmailConfirmed.GetHashCode());
            hashCode = hashCode * -1521134295 + (LockoutEnabled.GetHashCode());
            hashCode = hashCode * -1521134295 + (PhoneNumberConfirmed.GetHashCode());
            hashCode = hashCode * -1521134295 + (TwoFactorEnabled.GetHashCode());
            hashCode = hashCode * -1521134295 + (AccessFailedCount?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Name?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Email?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PhoneNumber?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LockoutEndDate?.GetHashCode() ?? 0);
            return(hashCode);
        }
        private Order(OrderId orderId, BuyerId buyerId, IEnumerable <OrderLine> lines)
        {
            this.Id      = orderId;
            this.BuyerId = buyerId;
            this.lines   = lines.ToList();

            this.AddDomainEvent(new OrderPlaced(this.Id, this.lines.Select(l => l.ItemId)));
        }
Exemple #4
0
        public async Task HandleAsync(PlaceOrderRequest command)
        {
            OrderId orderId = new OrderId(command.OrderId);
            BuyerId buyerId = new BuyerId(command.BuyerId);
            //Order order = Order.PlaceOrder(orderId, buyerId, command.ItemQuentities.Select(id => (id.Quantity, new ItemId(id.ItemId))));

            //orderRepository.Add(order);

            await orderRepository.UnitOfWork.SaveEntitiesAsync().ConfigureAwait(false);
        }
Exemple #5
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ DocumentId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ BuyerId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ PurchasedAt.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (TransactionId != null ? TransactionId.GetHashCode() : 0);
         return(hashCode);
     }
 }
        public GarmentSewingOut(Guid identity, string sewingOutNo, BuyerId buyerId, string buyerCode, string buyerName, UnitDepartmentId unitToId, string unitToCode, string unitToName, string sewingTo, DateTimeOffset sewingOutDate, string rONo, string article, UnitDepartmentId unitId, string unitCode, string unitName, GarmentComodityId comodityId, string comodityCode, string comodityName, bool isDifferentSize) : base(identity)
        {
            Validator.ThrowIfNull(() => unitId);
            Validator.ThrowIfNull(() => unitToId);
            Validator.ThrowIfNull(() => rONo);

            //MarkTransient();

            Identity        = identity;
            SewingOutNo     = sewingOutNo;
            SewingTo        = sewingTo;
            UnitToId        = unitToId;
            UnitToCode      = unitToCode;
            UnitToName      = unitToName;
            SewingOutDate   = sewingOutDate;
            RONo            = rONo;
            Article         = article;
            UnitId          = unitId;
            UnitCode        = unitCode;
            UnitName        = unitName;
            ComodityId      = comodityId;
            ComodityCode    = comodityCode;
            ComodityName    = comodityName;
            BuyerCode       = buyerCode;
            BuyerId         = buyerId;
            BuyerName       = buyerName;
            IsDifferentSize = isDifferentSize;

            ReadModel = new GarmentSewingOutReadModel(Identity)
            {
                SewingOutNo     = SewingOutNo,
                SewingTo        = SewingTo,
                UnitToId        = UnitToId.Value,
                UnitToCode      = UnitToCode,
                UnitToName      = UnitToName,
                SewingOutDate   = SewingOutDate,
                RONo            = RONo,
                Article         = Article,
                UnitId          = UnitId.Value,
                UnitCode        = UnitCode,
                UnitName        = UnitName,
                ComodityId      = ComodityId.Value,
                ComodityCode    = ComodityCode,
                ComodityName    = ComodityName,
                BuyerCode       = BuyerCode,
                BuyerId         = BuyerId.Value,
                BuyerName       = BuyerName,
                IsDifferentSize = IsDifferentSize,
            };

            ReadModel.AddDomainEvent(new OnGarmentSewingOutPlaced(Identity));
        }
        public GarmentExpenditureGood(Guid identity, string expenditureGoodNo, string expenditureType, UnitDepartmentId unitId, string unitCode, string unitName, string rONo, string article, GarmentComodityId comodityId, string comodityCode, string comodityName, BuyerId buyerId, string buyerCode, string buyerName, DateTimeOffset expenditureDate, string invoice, string contractNo, double carton, string description, bool isReceived) : base(identity)
        {
            Validator.ThrowIfNull(() => unitId);

            //MarkTransient();
            ExpenditureGoodNo = expenditureGoodNo;
            Identity          = identity;
            ExpenditureType   = expenditureType;
            UnitId            = unitId;
            UnitCode          = unitCode;
            UnitName          = unitName;
            RONo            = rONo;
            Article         = article;
            ComodityId      = comodityId;
            ComodityCode    = comodityCode;
            ComodityName    = comodityName;
            BuyerId         = buyerId;
            BuyerCode       = buyerCode;
            BuyerName       = buyerName;
            ExpenditureDate = expenditureDate;
            Invoice         = invoice;
            ContractNo      = contractNo;
            Carton          = carton;
            Description     = description;
            IsReceived      = isReceived;

            ReadModel = new GarmentExpenditureGoodReadModel(Identity)
            {
                ExpenditureGoodNo = ExpenditureGoodNo,
                ExpenditureType   = ExpenditureType,
                ExpenditureDate   = ExpenditureDate,
                RONo         = RONo,
                Article      = Article,
                UnitId       = UnitId.Value,
                UnitCode     = UnitCode,
                UnitName     = UnitName,
                BuyerCode    = BuyerCode,
                BuyerName    = BuyerName,
                BuyerId      = BuyerId.Value,
                ComodityId   = ComodityId.Value,
                ComodityCode = ComodityCode,
                ComodityName = ComodityName,
                Invoice      = Invoice,
                ContractNo   = ContractNo,
                Carton       = Carton,
                Description  = Description,
                IsReceived   = IsReceived
            };

            ReadModel.AddDomainEvent(new OnGarmentExpenditureGoodPlaced(Identity));
        }
        public Order(OrderId id, BuyerId buyerId, Address address, IEnumerable <OrderItem> orderItems, OrderStatus status, int?version = null)
        {
            Id         = id;
            BuyerId    = buyerId;
            Address    = address;
            Items      = orderItems ?? throw new EmptyOrderItemsException(id);
            Status     = status;
            TotalPrice = Items.Sum(item => item.Price);

            CheckRule(new MinimumAmountOfASingleOrderShouldBeAtLeast10(TotalPrice));
            CheckRule(new AmountOfASingleOrderCannotExceed100k(TotalPrice));

            Version   = version ?? 1;
            CreatedAt = DateTime.UtcNow;
        }
        public GarmentExpenditureGoodReturn(Guid identity, string returNo, string returType, UnitDepartmentId unitId, string unitCode, string unitName, string rONo, string article, GarmentComodityId comodityId, string comodityCode, string comodityName, BuyerId buyerId, string buyerCode, string buyerName, DateTimeOffset returDate, string invoice, string returDesc) : base(identity)
        {
            Validator.ThrowIfNull(() => unitId);

            //MarkTransient();
            ReturNo      = returNo;
            Identity     = identity;
            ReturType    = returType;
            UnitId       = unitId;
            UnitCode     = unitCode;
            UnitName     = unitName;
            RONo         = rONo;
            Article      = article;
            ComodityId   = comodityId;
            ComodityCode = comodityCode;
            ComodityName = comodityName;
            BuyerId      = buyerId;
            BuyerCode    = buyerCode;
            BuyerName    = buyerName;
            ReturDate    = returDate;
            Invoice      = invoice;
            ReturDesc    = returDesc;

            ReadModel = new GarmentExpenditureGoodReturnReadModel(Identity)
            {
                ReturNo      = ReturNo,
                ReturType    = ReturType,
                ReturDate    = ReturDate,
                RONo         = RONo,
                Article      = Article,
                UnitId       = UnitId.Value,
                UnitCode     = UnitCode,
                UnitName     = UnitName,
                BuyerCode    = BuyerCode,
                BuyerName    = BuyerName,
                BuyerId      = BuyerId.Value,
                ComodityId   = ComodityId.Value,
                ComodityCode = ComodityCode,
                ComodityName = ComodityName,
                Invoice      = Invoice,
                ReturDesc    = ReturDesc
            };

            ReadModel.AddDomainEvent(new OnGarmentExpenditureGoodReturnPlaced(Identity));
        }
 public GarmentExpenditureGoodReturn(GarmentExpenditureGoodReturnReadModel readModel) : base(readModel)
 {
     ReturNo      = readModel.ReturNo;
     RONo         = readModel.RONo;
     Article      = readModel.Article;
     UnitId       = new UnitDepartmentId(readModel.UnitId);
     UnitCode     = readModel.UnitCode;
     UnitName     = readModel.UnitName;
     BuyerCode    = readModel.BuyerCode;
     BuyerName    = readModel.BuyerName;
     BuyerId      = new BuyerId(readModel.BuyerId);
     ComodityId   = new GarmentComodityId(readModel.ComodityId);
     ComodityName = readModel.ComodityName;
     ComodityCode = readModel.ComodityCode;
     ReturDate    = readModel.ReturDate;
     ReturType    = readModel.ReturType;
     Invoice      = readModel.Invoice;
     ReturDesc    = readModel.ReturDesc;
 }
 public GarmentSewingOut(GarmentSewingOutReadModel readModel) : base(readModel)
 {
     SewingOutNo     = readModel.SewingOutNo;
     SewingTo        = readModel.SewingTo;
     UnitToId        = new UnitDepartmentId(readModel.UnitToId);
     UnitToCode      = readModel.UnitToCode;
     UnitToName      = readModel.UnitToName;
     SewingOutDate   = readModel.SewingOutDate;
     RONo            = readModel.RONo;
     Article         = readModel.Article;
     UnitId          = new UnitDepartmentId(readModel.UnitId);
     UnitCode        = readModel.UnitCode;
     UnitName        = readModel.UnitName;
     ComodityId      = new GarmentComodityId(readModel.ComodityId);
     ComodityCode    = readModel.ComodityCode;
     ComodityName    = readModel.ComodityName;
     BuyerCode       = readModel.BuyerCode;
     BuyerId         = new BuyerId(readModel.BuyerId);
     BuyerName       = readModel.BuyerName;
     IsDifferentSize = readModel.IsDifferentSize;
 }
 public GarmentExpenditureGood(GarmentExpenditureGoodReadModel readModel) : base(readModel)
 {
     ExpenditureGoodNo = readModel.ExpenditureGoodNo;
     RONo            = readModel.RONo;
     Article         = readModel.Article;
     UnitId          = new UnitDepartmentId(readModel.UnitId);
     UnitCode        = readModel.UnitCode;
     UnitName        = readModel.UnitName;
     BuyerCode       = readModel.BuyerCode;
     BuyerName       = readModel.BuyerName;
     BuyerId         = new BuyerId(readModel.BuyerId);
     ComodityId      = new GarmentComodityId(readModel.ComodityId);
     ComodityName    = readModel.ComodityName;
     ComodityCode    = readModel.ComodityCode;
     ExpenditureDate = readModel.ExpenditureDate;
     ExpenditureType = readModel.ExpenditureType;
     Invoice         = readModel.Invoice;
     ContractNo      = readModel.ContractNo;
     Carton          = readModel.Carton;
     Description     = readModel.Description;
     IsReceived      = readModel.IsReceived;
 }
 public void Apply(OrderBuyerChangedDomainEvent aggregateEvent)
 {
     _buyerId = aggregateEvent.BuyerId;
 }
 public void SetBuyerId(BuyerId buyerId)
 {
     Emit(new OrderBuyerChangedDomainEvent(buyerId));
 }
 public static Order PlaceOrder(OrderId orderId, BuyerId buyerId, IEnumerable <(decimal quantity, ItemId itemId)> lines)
 public OrderBuyerChangedDomainEvent(BuyerId buyerId)
 {
     this.BuyerId = buyerId;
 }