Example #1
0
        public void AddCustomer(Customer customer)
        {
            repo.AddCustomer(customer);
            repo.SaveChanges();

            this.Clients.Group("customers").refreshCustomers();
        }
Example #2
0
        public void UpdateCustomer(Customer customer)
        {
            repo.UpdateCustomer(customer);
            repo.SaveChanges();

            this.Clients.Group("customers").refreshCustomers();
            this.Clients.Group("customer:" + customer.ID).returnUpdateCustomer(customer);
        }
        public void EF_Customer_Poco_Add()
        {
            using (var cc = new CustomerContext())
            {
                cc.Database.Delete();
                cc.Database.Create();
            }
            Left4Edit.Models.Repo.ICustomerRepo repo =
                new Left4Edit.Models.Repo.EFCustomerRepo();

            Customer pocoCustomer = new Customer()
            {
                Name = "Poco Inc",
                Symbol = "POI",
                Contacts = new List<Contact>()
                {
                    new Contact()
                    {
                        FirstName = "No way",
                        LastName = "This works!",
                        Email = "*****@*****.**"
                    }
                }
            };

            repo.AddCustomer(pocoCustomer);
            repo.SaveChanges();

            Assert.IsTrue(repo.GetCustomers().First().Name == "Poco Inc");
            Assert.IsTrue(repo.GetCustomers().First().Contacts.First().FirstName == "No way");
        }
        public static IEnumerable<Customer> CreateTestCustomer_Mem()
        {
            // Preparation
            var customer = new Customer();
            var contact1 = new Contact();
            var contact2 = new Contact();
            var node1 = new Node();
            var node2 = new Node();
            var node3 = new Node();
            var credential1 = new Credential();
            var credential2 = new Credential();
            var credential3 = new Credential();

            // Build customer
            customer.Name = "Test Customer";
            customer.Symbol = "ASA";

            // Build contact1
            contact1.FirstName = "Anita";
            contact1.LastName = "Neal";
            contact1.Email = "*****@*****.**";
            contact1.MyCustomer = customer;

            // Build contact2
            contact2.FirstName = "Monster";
            contact2.LastName = "Energy";
            contact2.Email = "*****@*****.**";
            contact2.MyCustomer = customer;

            // build node1
            node1.Address = "node1.billmcg.com";
            node1.Name = "Node1 is best node!";
            node1.Comment = "No comment here";
            node1.MyCustomer = customer;

            // build node2
            node2.Address = "node2.billmcg.com";
            node2.Name = "Node2 FTW!";
            node2.Comment = "Worst Connection US";
            node2.MyCustomer = customer;

            // build node3
            node2.Address = "node3.billmcg.com";
            node2.Name = "Test Server";
            node3.Comment = "Use RDP fool";
            node3.MyCustomer = customer;

            // build credential1
            credential1.Domain = "SPLITH";
            credential1.UserName = "******";
            credential1.Password = "******";

            // build credential2
            credential2.Domain = "AURORA_NT";
            credential2.UserName = "******";
            credential2.Password = "******";

            // build credential3
            credential3.Domain = "AURORA_NT";
            credential3.UserName = "******";
            credential3.Password = "******";

            // assembly
            customer.Contacts.Add(contact1);
            customer.Contacts.Add(contact2);

            customer.Credentials.Add(credential2);
            customer.Credentials.Add(credential3);

            customer.Nodes.Add(node1);
            customer.Nodes.Add(node2);
            customer.Nodes.Add(node3);

            node1.Credentials.Add(credential1);

            return new List<Customer>(new Customer[] { customer });
        }
        public void DeleteCustomer_FromPOCO()
        {
            using (var cc = new CustomerContext())
            {
                cc.Database.Delete();
                cc.Database.Create();
            }

            var repo = new Left4Edit.Models.Repo.EFCustomerRepo();
            repo.AddCustomer(CreateTestCustomer_EF().First());
            repo.SaveChanges();

            var existingCustomer = repo.GetCustomers().First();
            Customer customerToDelete = new Customer()
            {
                ID = existingCustomer.ID,
                Name = "Test Customer",
                Symbol = "ASA"
            };

            repo.DeleteCustomer(customerToDelete);
            repo.SaveChanges();

            Assert.IsTrue(repo.GetCustomers().Count() == 0);
        }