Exemplo n.º 1
0
 public bool Add(Subscriber aggregate)
 {
     using (var db = new CommandModelDatabase())
     {
         db.Subscribers.Add(aggregate);
         return db.SaveChanges() > 0;
     }
 }
Exemplo n.º 2
0
 public int AddAndReturnKey(Order aggregate)
 {
     using (var db = new CommandModelDatabase())
     {
         db.Entry(aggregate.Buyer).State = EntityState.Unchanged;
         db.Orders.Add(aggregate);
         if (db.SaveChanges() > 0)
         {
             return aggregate.OrderId;
         }
         return 0;
     }
 }
Exemplo n.º 3
0
 public bool Save(Customer aggregate)
 {
     using (var db = new CommandModelDatabase())
     {
         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;
         }
     }
 }