コード例 #1
0
 public void Update(Product product)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.Entry(product).State = System.Data.Entity.EntityState.Modified;
         onlineShoppingContext.SaveChanges();
     }
 }
コード例 #2
0
 public void AddUser(Account account)
 {
     using (OnlineShoppingContext context = new OnlineShoppingContext())
     {
         context.Accounts.Add(account);
         context.SaveChanges();
     }
 }
コード例 #3
0
 public void  AddProduct(Product product)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.products.Add(product);
         onlineShoppingContext.SaveChanges();
     }
 }
コード例 #4
0
 public void Update(Category category)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.Entry(category).State = System.Data.Entity.EntityState.Modified;
         onlineShoppingContext.SaveChanges();
     }
 }
コード例 #5
0
 public void AddCategory(Category category)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.Categories.Add(category);
         onlineShoppingContext.SaveChanges();
     }
 }
コード例 #6
0
 public void Delete(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         Product product = onlineShoppingContext.products.Find(id);
         onlineShoppingContext.products.Remove(product);
         onlineShoppingContext.SaveChanges();
     }
 }
コード例 #7
0
 public void Delete(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         Category category = onlineShoppingContext.Categories.Find(id);
         onlineShoppingContext.Categories.Remove(category);
         onlineShoppingContext.SaveChanges();
     }
 }