public bool Add(Subscriber aggregate) { using (var db = new DomainModelFacade()) { db.Subscribers.Add(aggregate); return(db.SaveChanges() > 0); } }
public int AddAndReturnKey(Order aggregate) { using (var db = new DomainModelFacade()) { db.Entry(aggregate.Buyer).State = EntityState.Unchanged; db.Orders.Add(aggregate); if (db.SaveChanges() > 0) { return(aggregate.OrderId); } return(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); } } }