Example #1
0
        public async Task EntityFrameworkRepositoryTests_SaveAndLoadAggregateRootTestAsync()
        {
            EFCustomer customer = new EFCustomer
            {
                Address  = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };
            IRepository <EFCustomer> customerRepository = ServiceLocator.Instance.GetService <IRepository <EFCustomer> >();

            customerRepository.Add(customer);
            await customerRepository.Context.CommitAsync();

            var        key       = customer.ID;
            EFCustomer customer2 = customerRepository.GetByKey(key);

            customerRepository.Context.Dispose();

            Assert.AreEqual(customer.UserName, customer2.UserName);
            Assert.AreEqual(customer.Password, customer2.Password);
            Assert.AreEqual(customer.Address.City, customer2.Address.City);
            Assert.AreEqual(customer.Address.Country, customer2.Address.Country);
            Assert.AreEqual(customer.Address.State, customer2.Address.State);
            Assert.AreEqual(customer.Address.Street, customer2.Address.Street);
            Assert.AreEqual(customer.Address.Zip, customer2.Address.Zip);
        }
Example #2
0
        private void CustomerDBTest()
        {
            try
            {
                var customerService = new EFCustomer();

                //Customer newCust = new Customer();
                //newCust.idCustomer = "Customer01";
                //newCust.CustName = "Customer 01";
                //newCust.Active = true;
                //newCust.VATNum = "0101010101";
                //newCust.ShipingAddress = "Customer 01 Shiping Address";
                //newCust.BillingAddress = "Customer 01 Billing Address";
                //newCust.ContactName = "Customer 01 Contact Name";
                //newCust.ContactPhone = "111223344";
                //newCust.idIncoterm = 1;
                //newCust.idPaymentTerms = 2;
                //newCust.Currency = "euro";

                //var res = customerService.NewCustomer(newCust);

                //Customer customer;
                //customer = customerService.GetCustomerById("Customer01");
                //customer.ContactPhone = "5555667788";
                //customer.ShippingAddress += " X";
                //customer.BillingAddress += " X";

                //customerService.UpdateCustomer(customer);

                //customer = customerService.GetCustomerById("Customer01");
                //customer.ContactPhone = "999112233";
                //customer.ShippingAddress += " X";
                //customer.BillingAddress += " X";

                //customerService.UpdateCustomer(customer);

                Customer newCust2 = new Customer();
                newCust2.IdCustomer   = "Customer02";
                newCust2.CustomerName = "Customer 02";
                newCust2.Active       = true;
                newCust2.VATNum       = "0202020202";
                //newCust2.ShippingAddress = "Customer 02 Shiping Address";
                //newCust2.BillingAddress = "Customer 02 Billing Address";
                //newCust2.ContactName = "Customer 02 Contact Name";
                //newCust2.ContactPhone = "444332211";
                //newCust2.IdIncoterm = 3;
                //newCust2.IdPaymentTerms = 4;
                //newCust2.Currency = "US dolar";

                var res = customerService.NewCustomer(newCust2);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        public void EntityFrameworkRepositoryTests_SaveAggregateRootWithIDReturnedTest()
        {
            EFCustomer customer = new EFCustomer
            {
                Address  = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };

            IRepository <EFCustomer> customerRepository = ServiceLocator.Instance.GetService <IRepository <EFCustomer> >();

            customerRepository.Add(customer);
            customerRepository.Context.Commit();
            customerRepository.Context.Dispose();

            Assert.AreNotEqual(0, customer.ID);
        }
Example #4
0
        public void EntityFrameworkRepositoryTests_SaveAggregateRootTest()
        {
            EFCustomer customer = new EFCustomer
            {
                Address  = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };

            IRepository <EFCustomer> customerRepository = ServiceLocator.Instance.GetService <IRepository <EFCustomer> >();

            customerRepository.Add(customer);
            customerRepository.Context.Commit();
            customerRepository.Context.Dispose();

            int expected = 1;
            int actual   = Helper.ReadRecordCountFromEFTestDB(Helper.EF_Table_EFCustomers);

            Assert.AreEqual(expected, actual);
        }
Example #5
0
 public static EFCustomer CreateEFCustomer(int customerId,
             string name,
             string primaryContactInfo_EmailBag,
             string primaryContactInfo_AlternativeNames,
             string primaryContactInfo_ContactAlias_AlternativeNames,
             string primaryContactInfo_HomePhone_PhoneNumber,
             string primaryContactInfo_WorkPhone_PhoneNumber,
             string primaryContactInfo_MobilePhoneBag_PhoneNumber,
             string backupContactInfo_EmailBag,
             string backupContactInfo_AlternativeNames,
             string backupContactInfo_ContactAlias_AlternativeNames,
             string backupContactInfo_HomePhone_PhoneNumber,
             string backupContactInfo_WorkPhone_PhoneNumber,
             string backupContactInfo_MobilePhoneBag_PhoneNumber,
             global::System.DateTimeOffset auditing_ModifiedDate,
             string auditing_ModifiedBy,
             string auditing_Concurrency_Token)
 {
     EFCustomer eFCustomer = new EFCustomer();
     eFCustomer.CustomerId = customerId;
     eFCustomer.Name = name;
     eFCustomer.PrimaryContactInfo_EmailBag = primaryContactInfo_EmailBag;
     eFCustomer.PrimaryContactInfo_AlternativeNames = primaryContactInfo_AlternativeNames;
     eFCustomer.PrimaryContactInfo_ContactAlias_AlternativeNames = primaryContactInfo_ContactAlias_AlternativeNames;
     eFCustomer.PrimaryContactInfo_HomePhone_PhoneNumber = primaryContactInfo_HomePhone_PhoneNumber;
     eFCustomer.PrimaryContactInfo_WorkPhone_PhoneNumber = primaryContactInfo_WorkPhone_PhoneNumber;
     eFCustomer.PrimaryContactInfo_MobilePhoneBag_PhoneNumber = primaryContactInfo_MobilePhoneBag_PhoneNumber;
     eFCustomer.BackupContactInfo_EmailBag = backupContactInfo_EmailBag;
     eFCustomer.BackupContactInfo_AlternativeNames = backupContactInfo_AlternativeNames;
     eFCustomer.BackupContactInfo_ContactAlias_AlternativeNames = backupContactInfo_ContactAlias_AlternativeNames;
     eFCustomer.BackupContactInfo_HomePhone_PhoneNumber = backupContactInfo_HomePhone_PhoneNumber;
     eFCustomer.BackupContactInfo_WorkPhone_PhoneNumber = backupContactInfo_WorkPhone_PhoneNumber;
     eFCustomer.BackupContactInfo_MobilePhoneBag_PhoneNumber = backupContactInfo_MobilePhoneBag_PhoneNumber;
     eFCustomer.Auditing_ModifiedDate = auditing_ModifiedDate;
     eFCustomer.Auditing_ModifiedBy = auditing_ModifiedBy;
     eFCustomer.Auditing_Concurrency_Token = auditing_Concurrency_Token;
     return eFCustomer;
 }
 public HomeController(EFCustomer customer)
 {
     _Customer = customer;
 }
Example #7
0
 public ActionResult Index(Customer fc)
 {
     cust = new EFCustomer();
     cust.save(fc);
     return(View());
 }