Example #1
0
 public bool Add(Customer aggregate)
 {
     using (var db = new DomainModelFacade())
     {
         db.Customers.Add(aggregate);
         return db.SaveChanges() >0;
     }
 }
Example #2
0
 public bool Add(Customer aggregate)
 {
     using (var db = new CommandModelDatabase())
     {
         db.Customers.Add(aggregate);
         return db.SaveChanges() >0;
     }
 }
Example #3
0
 protected Order(int orderId, Customer customer)
 {
     OrderId = orderId;
     State = OrderState.Pending;
     Total = Money.Zero;
     Date = DateTime.Today;
     Items = new Collection<OrderItem>();
     Buyer = customer;
 }
Example #4
0
 public static Customer CreateNew(Gender gender, string name, string firstname, string lastname, string email)
 {
     var customer = new Customer
     {
         CustomerId = name, 
         Address = Address.Create(), 
         Payment = NullCreditCard.Instance,
         Email = email,
         FirstName = firstname,
         LastName = lastname,
         Gender = gender
     };
     return customer;
 }
Example #5
0
 public bool Save(Customer aggregate)
 {
     using (var db = new DomainModelFacade())
     {
         try
         {
             var customer = (from c in db.Customers where c.CustomerId == aggregate.CustomerId select c).Single();
             customer.SetAddress(aggregate.Address);
             customer.SetAvatar(aggregate.Avatar);
             customer.SetPaymentDetails(aggregate.Payment);
             customer.SetPasswordHash(aggregate.PasswordHash);
             var changes = db.SaveChanges();
             return changes >0;
         }
         catch (InvalidOperationException)
         {
             return false;
         }
     }
 }
Example #6
0
 public bool Delete(Customer aggregate)
 {
     throw new NotImplementedException();
 }
Example #7
0
 // The class has no public constructor because instances of it will only be 
 // created materializing from storage. An O/RM will do it and it can use
 // the protected ctor.
 public static Order CreateNew(int id, Customer customer)
 {
     var order = new Order(id, customer);
     return order;
 }
Example #8
0
 public static ShoppingCart CreateEmpty(Customer buyer)
 {
     var model = new ShoppingCart {Buyer = buyer};
     return model;
 }