forked from JoergEg/CQRS-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created own dto for customer relocated view
- Loading branch information
JoergEg
committed
Mar 14, 2011
1 parent
ef01dac
commit 0d2baa4
Showing
17 changed files
with
164 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using CQRSSample.Domain.Events; | ||
using Raven.Client; | ||
|
||
namespace CQRSSample.ReadModel | ||
{ | ||
public class CustomerAddressView : HandlesEvent<CustomerCreatedEvent>, HandlesEvent<CustomerRelocatedEvent> | ||
{ | ||
private readonly IDocumentStore _documentStore; | ||
|
||
public CustomerAddressView(IDocumentStore documentStore) | ||
{ | ||
_documentStore = documentStore; | ||
} | ||
|
||
public void Handle(CustomerRelocatedEvent @event) | ||
{ | ||
using (var session = _documentStore.OpenSession()) | ||
{ | ||
var dto = session.Load<CustomerAddressDto>(Dto.GetDtoIdOf<CustomerAddressDto>(@event.AggregateId)); | ||
dto.Street = @event.Street; | ||
dto.StreetNumber = @event.StreetNumber; | ||
dto.PostalCode = @event.PostalCode; | ||
dto.City = @event.City; | ||
session.SaveChanges(); | ||
} | ||
} | ||
|
||
public void Handle(CustomerCreatedEvent @event) | ||
{ | ||
using(var session = _documentStore.OpenSession()) | ||
{ | ||
var dto = new CustomerAddressDto { AggregateRootId = @event.AggregateId, CustomerName = @event.CustomerName, Street = @event.Street, StreetNumber = @event.StreetNumber, PostalCode = @event.PostalCode, City = @event.City }; | ||
session.Store(dto); | ||
session.SaveChanges(); | ||
} | ||
} | ||
} | ||
|
||
public class CustomerAddressDto : Dto | ||
{ | ||
public string City { get; set; } | ||
|
||
public string PostalCode { get; set; } | ||
|
||
public string StreetNumber { get; set; } | ||
|
||
public string Street { get; set; } | ||
|
||
public string CustomerName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
CQRSSample.WpfClient/Modules/CustomerDetails/IShowCustomerDetails.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace CQRSSample.WpfClient.Modules.CustomerDetails | ||
{ | ||
public interface IShowCustomerDetails | ||
{ | ||
void WithCustomer(string customerId); | ||
|
||
Guid GetCustomerId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.