コード例 #1
0
 public bool Add(Subscriber aggregate)
 {
     using (var db = new CommandModelDatabase())
     {
         db.Subscribers.Add(aggregate);
         return(db.SaveChanges() > 0);
     }
 }
コード例 #2
0
ファイル: OrderRepository.cs プロジェクト: stalla/NAAE
 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);
     }
 }
コード例 #3
0
ファイル: CustomerRepository.cs プロジェクト: stalla/NAAE
 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);
         }
     }
 }