public bool Add(Customer aggregate) { using (var db = new DomainModelFacade()) { db.Customers.Add(aggregate); return db.SaveChanges() >0; } }
public bool Add(Customer aggregate) { using (var db = new CommandModelDatabase()) { db.Customers.Add(aggregate); return db.SaveChanges() >0; } }
protected Order(int orderId, Customer customer) { OrderId = orderId; State = OrderState.Pending; Total = Money.Zero; Date = DateTime.Today; Items = new Collection<OrderItem>(); Buyer = customer; }
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; }
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; } } }
public bool Delete(Customer aggregate) { throw new NotImplementedException(); }
// 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; }
public static ShoppingCart CreateEmpty(Customer buyer) { var model = new ShoppingCart {Buyer = buyer}; return model; }