Beispiel #1
0
        public async Task <string> Handle(CreateCustomerRequest request, CancellationToken cancellationToken)
        {
            try
            {
                var customer = new CustomerModel(request.FirstName, request.LastName, request.Email, request.Mobile);

                request.Addresses?.ForEach(x => customer.AddAddress(new AddressModel(x.Type, x.Address1, x.Address2, x.State, x.Country, x.Pincode)));

                var result = await _repository.CreateAsync(customer);

                await _mediator.Publish(new CustomerCreatedEvent(result)).ConfigureAwait(false);

                return("success");
            }
            catch (System.Exception)
            {
                throw;
            }
        }