There is an Entity:Customer and if the Customer changes his name ( via Web UI), the Customer Service must detect this change and send an email to Administrator.
Now should this responsibility be assigned to the Customer? Something like
c.HasChangedName(NewName); where c is a reference to the Customer
There could be other activities undertaken by the CustomerService based on such changes to the Customer entity. Email is just an example.
By my opinion, Customer aggregate root (I suppose it is an aggregate root and not an entity) should publish CustomerNameChanged event in
customer.ChangeName(string newname)
method call.
You could look at some implementation sample in Greg Young's github repository.
Or if don't want to use event sourcing you could take a look at Udi Dahan's post about domain events
Related
The system I want to model is an application called GetKnowSoft. The example is simple: there is a customer, a manager, and a register customer use case. Who registers the customer in the application is the manager.
I connect the manager to the client. The question is: Do I also tie the customer to the use case, even though the customer has no active role?
If the customer doesn’t directly interact with the app, it should not be an actor.
If the customer would have some interactions (e.g. enters name and address that is validated by the manager, or receives a confirmation email from the app) then it should be an actor.
The docs only covers the case where the payment method is created by the frontend (JS). But there is a risk that the user leaves the website before the frontend sends the information to the backend that the card has been added (and its ID).
In order to make a payment, I need ID of the payment method. I don't want to query Stripe's API for user cards IDs every time before making a payment, so I want to save the payment method ID in my local database. I also want to allow the user to define more payment methods and choose the default one.
Is there a reason you are using the non-recommended workflow you linked to? The most up-to-date version can be found here
Have you checked out using webhook listeners? I use them to create/update my local records.
In the workflow you reference, 3 webhook events potentially fire. First the setup_intent.created event is triggered when your server code generates the SetupIntent and its client_secret. Then, when the user fills out whatever Payment or Card element you instantiate and your frontend code calls the stripe.confirmCardSetup() (or stripe.confirmSetup() in the case of a PaymentElement), both the setup_intent.succeeded and payment_method.attached events will fire.
This last one will POST the payment_method object that was just attached to your customer back to your system. This object will have both the Payment Method ID as well as the associated Customer ID. You can use these to update your local records to map payment methods to customers in your server and avoid unnecessary API calls.
I have the follow scenario:
You need to create a Request before it to become a Shop and to get a Owner Account.
So one day you register a Request.
2 days after a manager reviews and approves your Request and it means that the system have to create the Shop and Owner Account.
In my model, I thought that Request, Shop and Owner Account were 3 Aggregate Roots, but then I read that I cannot update more than one aggregate in one transaction because they may be (and in fact they are, because Owner Account is in an external authentication service) in separated db servers.
The thing is.. I still have a Request, and when it gets approved I need to create 2 aggregate roots, the Shop (with all the shop attributes, I only have some invariants with the data, like the limit of contact emails or phones) and the Owner Account.
Then one Owner Account can be allowed to edit someone else's Shop (like a collaborator)
How could I model it?
Thanks!
From your requirements, my design would be:
Two bounded contexts:
Shopping: It has two aggregates ( Request and Shop ).
Authentication: One aggregate ( OwnerAcount ).
There exists eventual consistency:
(1) Request aggregate would have a method "aprove". This method creates the RequestAproved event.
(2) Shopping BC publishes the RequestAproved event.
(3) Authentication BC is a subscriber to this event. It reacts to the event creating an OwnerAcount aggregate.
(4) The constructor method of OwnerAcount aggregate creates the OwnerAcountCreated event.
(5) Auth BC publishes the OwnerAcountCreated event.
(6) Shopping BC is a subscriber to this event. It reacts to the event creating a Shop aggregate.
Transaction creating the Shop aggregate is different from the one that created the Request aggregate.
Here's a diagram:
(Note: There's a message queue for each event type. Another option would be just one queue for all event types)
I'm working on an event sourced application following DDD and CQRS principles, which allows the posting of ads to sell goods.
There's one specific invariant that i'm trying to model which would seem to involve a bulk update of AR's, and I don't really know how to go about it.
The invariant is as such:
A Member can post an ad
A Member could be banned by an Admin
If a Member is banned, his ads must be suspended
for the purposes of the discussion, an Ad needs to have a status, as a Member can buy an item by clicking on an ad, so it's important to know if an ad is active.
I have designed my aggregate roots as such:
Member
Ad
Order
A Member can be a buyer or a seller, depending on the context, so I decorate the member object as needed.
When ads are published, they are of course inserted in a read model.
Now, when a Member is banned, there's an event associated that the Member AR triggers.
MemberWasBanned (MemberId)
My question is how do I go about finding every Ad that the member owns, and suspend them?
While I could rely on the member status for a buy transaction, it's important that the Ad tracks its status as there are other similar operations that could trigger the sending of an email for instance to the member indicating that his ads were suspended for such or such reason.
So my best approach after a lot of thinking is to create a long running process, in which I create a handler for MemberWasBanned, then go look for his active ads in the read model, and issue commands to suspend them one by one.
Am I missing something? I thought of using a process manager, but read that you shouldn't access the read side from a PM. In any case a PM in most cases determines the command sent to ONE AR.
Am I missing something?
If you have a messaging mechanism, maybe you can "explode" the MemberWasBanned event.
Publish the MemberWasBanned (or equivalent) event through your messaging pipeline, and subscribe to it from the context that handles ads. When this event is received in your messaging mechanism, you can explode it into multiple DisableAd events that will also be sent through your messaging system, each of them targetting one current ad of the banned member.
Each of these events, then, will only write on a single Aggregate (each ad, disabling it) when they're processed by the messaging mechanism.
Concurrently, the banned user will prevent further ads from being inserted, so you will be safe on that end as well.
I need send email to team members.The mail like the record is assigned to you.using either workflow or plugin.which means If I assigned a record to particular team I need send mail notification to that particular team members ...how to do this ???
What type of object are you talking about?
For anything that's owned by a user, you can create a workflow that is triggered whenever the object changes owners, the will send an e-mail to the new owner. Not too tricky.
sending an e-mail to an entire team is tricker. There are a couple different ways to accomplish this.
Distribution list.
Edit the team entity so that it contains a team e-mail. Create a distribution list that has all the members of the team on it. Create a workflow like you would with a user, and then send an e-mail to the distributon list address if there is a change in ownership
The disadvantage of this is that you have to manage the DL list and the teams in CRM separately. But it's quick.
Plug in.
Create a plug in that will fire when the ownership of the object changes. Make a linq query that will grab all the e-mail addresses of the users in the team. Create a foreach loop that will send out the e-mail to all those users.
This is the more difficult and time consuming of the options, but it's the right way to do it.
I've written a custom workflow library that can send an email to members of a team.
https://crm2011internalemail.codeplex.com/