Beispiel #1
0
        public void Handle(CustomerGetDetailsCommand command)
        {
            InfoAccumulator info = new InfoAccumulator();

            int customerId;

            try {
                customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator);
            } catch (Exception ex) {
                Log.Error(ex.Message);
                info.AddError("Invalid customer id.");
                SendReply(info, command);
                return;
            }

            Customer customer = CustomerQueries.GetCustomerById(customerId);
            IEnumerable <CustomerAddress> addresses = CustomerQueries.GetCustomerAddresses(customerId);
            IEnumerable <CustomerPhone>   phones    = CustomerQueries.GetCustomerPhones(customerId);
            var requesetedLoan = LoanQueries.GetCustomerRequestedLoan(customerId);

            SendReply(info, command, resp => {
                resp.PersonalDetails           = GetPersonalDetails(customer);
                resp.ContactDetails            = GetContactDetails(phones, customer);
                resp.CurrentLivingAddress      = GetCurrentLivingAddress(addresses, customer);
                resp.PreviousLivingAddress     = GetPreviousLivingAddress(addresses, customer);
                resp.AdditionalOwnedProperties = GetAdditionalOwnedProperties(addresses, customer)
                                                 .ToArray();
                resp.RequestedAmount = (decimal)requesetedLoan.Map(o => o.Amount.HasValue ? o.Amount.Value : 0);
            });
        }
Beispiel #2
0
        public CustomerDTO GetCurrentCustomer()
        {
            var user = User.Identity.GetUserId();

            return(cq.GetCustomerById(user));
        }