Beispiel #1
0
        public Customer GetCustomer(int id)
        {
            Customer cust = null;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                cust = repo.GetAsync(id).Result;
            }

            return(cust);
        }
Beispiel #2
0
        public bool DeleteCustomer(int id)
        {
            bool result = false;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                result = repo.DeleteAsync(id).Result;
            }

            return(result);
        }
Beispiel #3
0
        public int DeleteCustomer(List <int> idList)
        {
            int result = 0;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                result = repo.DeleteRangeAsync(idList).Result;
            }

            return(result);
        }
Beispiel #4
0
        public int AddCustomer(Customer customer)
        {
            int id = 0;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                id = repo.InsertAsync(customer).Result.Id;
            }

            return(id);
        }
Beispiel #5
0
        public void TestDBContext()
        {
            using (var db = new BikesAndBrewsContext())
            {
                // Read from the db

                //List<State> states = db.State.ToList();

                //foreach (var state in states)
                //{
                //    Console.WriteLine($"State: {state.Name}  Abbr: {state.ShortName}  Sales Tax {state.SalesTax}");
                //}

                Order order = db.Order.FirstOrDefault(o => o.Id == 90);

                Console.WriteLine($"{order.Id} {order.OrderDate}");
                //.Where(o => o.CustomerId == 90);
            }
        }