public Customer SaveNewCustomer(Customer newCustomer)
 {
     return Helper.RunInTransaction(() =>
         {
             var id = dal.SaveCustomer(newCustomer);
             return dal.RetrieveCustomer(id);
         });
 }
Exemple #2
0
 public int SaveCustomer(Customer customer)
 {
     if (customer.Id == 0)
     {
         customer.Id = new Random().Next();
     }
     customers.Add(customer);
     return customer.Id;
 }
 public Customer SaveNewCustomer(Customer newCustomer)
 {
     Console.WriteLine("Entering SaveNewCustomer with {0}", newCustomer);
     using (var transaction = new Transaction())
     {
         try
         {
             var id = dal.SaveCustomer(newCustomer);
             var customer = dal.RetrieveCustomer(id);
             transaction.Commit();
             Console.WriteLine("Exiting SaveNewCustomer with {0}", customer);
             return customer;
         }
         catch (Exception ex)
         {
             Console.WriteLine("Exception occured : {0}", ex.Message);
             transaction.RollBack();
             throw;
         }
     }
 }