private void OnAuctionCreated(AuctionCreated ev) { this.SellerId = ev.SellerId; this.Item = ev.Item; this.MinPrice = ev.MinPrice; this.WindowUtc = ev.WindowUtc; this.Running = true; this.Created = true; }
private bool VerifyEvent(AuctionCreated auctionCreated, CreateAuctionCommand command) { var v1 = auctionCreated != null; var v2 = auctionCreated.AuctionId != Guid.Empty; var v3 = auctionCreated.AuctionArgs.Product.Name.Equals(command.Product.Name) && auctionCreated.AuctionArgs.Product.Description.Equals(command.Product.Description); var v4 = auctionCreated.AuctionArgs.BuyNowPrice.Equals(command.BuyNowPrice); var v5 = auctionCreated.AuctionArgs.StartDate.Value.CompareTo(command.StartDate) == 0; var v6 = auctionCreated.AuctionArgs.Creator.UserId.Equals(user.UserIdentity.UserId); return(v1 && v2 && v3 && v4 && v5 && v6); }
public static CommandResult Handle(State state, CreateAuction createAuction) { switch (state) { case EmptyState _: var auctionCreated = AuctionCreated.Create(createAuction.Auction); return(CommandResultSuccess.Create(new List <EventPayload> { auctionCreated })); default: return(CommandResultFailure.Create("Auction already created")); } }
private void ApplyEvent(AuctionCreated @event) { AggregateId = @event.AuctionId; Create(@event.AuctionArgs, false); }