public void addPymentMethodWithEntityFramework()
        {
            var customer = new Customer { name = "Sciemniacz" };
            var creditCardPaymentMethod = new CreditCardPaymentMethod() { cardHolderName = "Roman", cardNumber = "123123", cardType = "visa", registrationDate = DateTime.Now, status = 1, AssignedTo = customer};
            var directDebitPaymentMethod = new DirectDebitPaymentMethod()
                                    {bankAccountNumber = "12345", holderName = "Roman", registrationDate = DateTime.Now, status = 2, AssignedTo = customer};
            customer.UsedPaymentMethod = creditCardPaymentMethod;
            var entities = new Entities();

            entities.AddToPaymentMethodSet(creditCardPaymentMethod);
            entities.AddToPaymentMethodSet(directDebitPaymentMethod);
            entities.SaveChanges();

            var entities1 = new Entities();
            List<PaymentMethod> paymentMethods = entities1.PaymentMethodSet
                .Where(x => x.registrationDate < DateTime.Now)
                .ToList();
            foreach (var paymentMethod in paymentMethods)
            {
                   Console.WriteLine(paymentMethod.GetType());
            }
        }
Beispiel #2
0
 public void ShouldRetrieveAllCustomerRelatioinshipsWithAPerformantQuery_EF()
 {
     using (new TransactionScope())
     {
         var customer = new Customer { name = "Test Customer" };
         var paymentMethod = new DirectDebitPaymentMethod
                                 {
                                     AssignedTo = customer,
                                     bankAccountNumber= "1234",
                                     holderName = "Test Customer",
                                     registrationDate= DateTime.Today,
                                     status = 1
                                 };
         customer.Services.Add(new Service { BoughtBy = customer, MonthlyFee = 20, Name = "Voip" });
         var entities = new Entities();
         entities.AddToCustomerSet(customer);
         entities.AddToPaymentMethodSet(paymentMethod);
         entities.SaveChanges();
         customer.UsedPaymentMethod = paymentMethod;
         entities.SaveChanges();
         entities = new Entities();
         List<Customer> customers = entities.CustomerSet.Include("UsedPaymentMethod").Include("Services").Where(
             x => x.name == "Test Customer").ToList();
         Assert.That(customers, Has.Count.EqualTo(1));
         Assert.That(customer.Services, Has.Count.EqualTo(1));
         Assert.That(customer.UsedPaymentMethod, Is.Not.Null);
     }
 }
 /// <summary>
 /// Create a new DirectDebitPaymentMethod object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="status">Initial value of the status property.</param>
 /// <param name="registrationDate">Initial value of the registrationDate property.</param>
 public static DirectDebitPaymentMethod CreateDirectDebitPaymentMethod(global::System.Int32 id, global::System.Byte status, global::System.DateTime registrationDate)
 {
     DirectDebitPaymentMethod directDebitPaymentMethod = new DirectDebitPaymentMethod();
     directDebitPaymentMethod.id = id;
     directDebitPaymentMethod.status = status;
     directDebitPaymentMethod.registrationDate = registrationDate;
     return directDebitPaymentMethod;
 }