private static void SetupDomainEventHandlers(IBus bus, IDocumentStore documentStore) { //TODO: Resolve through IoC var view = new CustomerListView(documentStore); bus.RegisterHandler<CustomerCreatedEvent>(view.Handle); bus.RegisterHandler<CustomerRelocatedEvent>(view.Handle); var addressView = new CustomerAddressView(documentStore); bus.RegisterHandler<CustomerCreatedEvent>(addressView.Handle); bus.RegisterHandler<CustomerRelocatedEvent>(addressView.Handle); }
private static void SetupDomainEventHandlers(IBus bus, IDocumentStore documentStore) { //TODO: Resolve through IoC var view = new CustomerListView(documentStore); bus.RegisterHandler <CustomerCreatedEvent>(view.Handle); bus.RegisterHandler <CustomerRelocatedEvent>(view.Handle); var addressView = new CustomerAddressView(documentStore); bus.RegisterHandler <CustomerCreatedEvent>(addressView.Handle); bus.RegisterHandler <CustomerRelocatedEvent>(addressView.Handle); }
public async Task <CustomerDetailView> GetDetailAsync(int customerId) { CustomerDetailView result = new CustomerDetailView(); var customerInfo = await _unitOfWork.CustomerRepository.GetAsync(customerId); if (customerInfo == null) { throw new RestException(HttpStatusCode.NotFound, new { customer = "Not found" }); } result.Id = customerInfo.Id; result.Name = customerInfo.Name; result.Email = customerInfo.Name; result.AddressLst = new List <CustomerAddressView>(); var addressLst = await _unitOfWork.CustomerAddressRepository.GetByCustomerAsync(customerInfo.Id); foreach (var address in addressLst) { if (address.AddressType != Address_Type.ClosedShop) { CustomerAddressView a = new CustomerAddressView() { Id = address.Id, AddressType = CodeTranslation.ToAddressTypeDescription(address.AddressType), Address1 = address.Address1, Address2 = address.Address2, ShopName = address.ShopName, CustomerId = address.CustomerId, City = address.City, State = address.State, ZipCode = address.ZipCode, }; result.AddressLst.Add(a); } } return(result); }