Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class BillingAddress {
  2. public Guid OrderId;
  3. public string StreetLine1;
  4. // etc.
  5. }
  6.  
  7. public class Order { // this is the domain object
  8. private Guid _id;
  9. private Status _status;
  10.  
  11. // note the behavior here - we throw an exception if it's not a valid state transition
  12. public Cancel() {
  13. if (_status == Status.Shipped)
  14. throw new InvalidOperationException("Can't cancel order after shipping.")
  15. _status = Status.Cancelled;
  16. }
  17.  
  18. // etc...
  19. }
  20.  
  21. public class Data.Order { // this is the persistence (EF) class
  22. public Guid Id;
  23. public Status Status;
  24. }
  25.  
  26. public interface IOrderRepository {
  27. // The implementation of this will:
  28. // 1. Load the EF class if it exists or new it up with the ID if it doesn't
  29. // 2. Map the domain class to the EF class
  30. // 3. Save the EF class to the DbContext.
  31. void Save(Order order);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement