add quick leads
All checks were successful
Build and Publish / build-release (push) Successful in 2m13s
All checks were successful
Build and Publish / build-release (push) Successful in 2m13s
This commit is contained in:
@@ -32,6 +32,21 @@ defmodule CustomerService.Aggregates.Customer do
|
||||
}
|
||||
end
|
||||
|
||||
@impl Aggregate
|
||||
def execute(%Customer{id: _id}, %Commands.UpdateCustomer{} = cmd) do
|
||||
%Events.CustomerUpdated{
|
||||
id: cmd.id,
|
||||
first_name: cmd.first_name,
|
||||
last_name: cmd.last_name,
|
||||
birth_date: cmd.birth_date,
|
||||
gender: cmd.gender,
|
||||
email: cmd.email,
|
||||
phone: cmd.phone,
|
||||
document_id: cmd.document_id,
|
||||
address: cmd.address
|
||||
}
|
||||
end
|
||||
|
||||
@impl Aggregate
|
||||
def apply(%Customer{} = c, %Events.CustomerCreated{} = e) do
|
||||
%__MODULE__{
|
||||
@@ -47,4 +62,19 @@ defmodule CustomerService.Aggregates.Customer do
|
||||
document_id: e.document_id
|
||||
}
|
||||
end
|
||||
|
||||
@impl Aggregate
|
||||
def apply(%Customer{} = c, %Events.CustomerUpdated{} = e) do
|
||||
%__MODULE__{
|
||||
c
|
||||
| first_name: e.first_name || c.first_name,
|
||||
last_name: e.last_name || c.last_name,
|
||||
birth_date: e.birth_date || c.birth_date,
|
||||
gender: e.gender || c.gender,
|
||||
email: e.email || c.email,
|
||||
phone: e.phone || c.phone,
|
||||
address: e.address || c.address,
|
||||
document_id: e.document_id || c.document_id
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user