Exemplo n.º 1
0
 public void Create(Order order)
 {
     using (var command = _context.CreateCommand())
     {
         command.CommandText = OrderRepository.CreateCommandCreateOrder();
         command.Parameters.Add(_context.CreateParameter("@Amount", order.Amount));
         command.Parameters.Add(_context.CreateParameter("@VAT", order.VAT));
         command.Parameters.Add(_context.CreateParameter("@CustomerId", order.CustomerId));
         command.ExecuteNonQuery();
     }
 }
        public Customer Load(int customerId)
        {
            List <Customer> customers = new List <Customer>();

            using (var command = _context.CreateCommand())
            {
                command.CommandText = CustomerRepository.CreateCommandGetCustomer();
                command.Parameters.Add(_context.CreateParameter("@Id", customerId));
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    customers.Add(CustomerFromReader(reader, false));
                }
                reader.Close();
            }
            _context.SaveChanges();
            return(customers.FirstOrDefault());
        }