예제 #1
0
 public static void AddCoffee(Drink d)
 {
     using (CoffeeDatabaseEntities context = new CoffeeDatabaseEntities())
     {
         context.Drink.Add(d);
         context.SaveChanges();
     }
 }
예제 #2
0
        public static void DeleteCustomer(Customer c)
        {
            var context = new CoffeeDatabaseEntities();

            context.Entry(c).State = EntityState.Deleted;

            context.SaveChanges();
        }
예제 #3
0
 public static List <Drink> GetAllCoffee()
 {
     using (CoffeeDatabaseEntities context = new CoffeeDatabaseEntities())
     {
         List <Drink> allCoffee =
             context.Drink.ToList();
         return(allCoffee);
     }
 }
예제 #4
0
 public static void Update(Drink d)
 {
     using (CoffeeDatabaseEntities context = new CoffeeDatabaseEntities())
     {
         context.Entry(d).State = System.Data.Entity.EntityState.Detached;
         context.Drink.Add(d);
         context.Entry(d).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #5
0
        public static Customer Update(Customer c)
        {
            CoffeeDatabaseEntities context = new CoffeeDatabaseEntities();

            context.Entry(c).State = EntityState.Modified;

            context.SaveChanges();

            return(c);
        }
예제 #6
0
        public static Customer AddCustomer(Customer c)
        {
            CoffeeDatabaseEntities context = new CoffeeDatabaseEntities();

            context.Customer.Add(c);

            context.SaveChanges();

            return(c);
        }
예제 #7
0
        public static List <Customer> GetCustomers()
        {
            var context = new CoffeeDatabaseEntities();

            //SELECT * FROM Customers
            List <Customer> allCustomers =
                (from c in context.Customer
                 select c).ToList();

            return(allCustomers);
        }