示例#1
0
 public Product GetProducts(int ID)
 {
     using (var Context = new EcContext())
     {
         return(Context.products.Find(ID));
     }
 }
示例#2
0
 public List <Product> GetProducts()
 {
     using (var Context = new EcContext())
     {
         return(Context.products.ToList());
     }
 }
示例#3
0
 public List <Category> GetCategories()
 {
     using (var Context = new EcContext())
     {
         return(Context.Categories.ToList());
     }
 }
示例#4
0
 public Category GetCategories(int ID)
 {
     using (var Context = new EcContext())
     {
         return(Context.Categories.Find(ID));
     }
 }
示例#5
0
 public void UpdateProduct(Product product)
 {
     using (var Context = new EcContext())
     {
         Context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         Context.SaveChanges();
     }
 }
示例#6
0
 public void SaveProduct(Product product)
 {
     using (var Context = new EcContext())
     {
         Context.products.Add(product);
         Context.SaveChanges();
     }
 }
示例#7
0
 public void UpdateCategory(Category category)
 {
     using (var Context = new EcContext())
     {
         Context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         Context.SaveChanges();
     }
 }
示例#8
0
 public void SaveCategory(Category category)
 {
     using (var Context = new EcContext())
     {
         Context.Categories.Add(category);
         Context.SaveChanges();
     }
 }
示例#9
0
 public void DeleteProduct(int ID)
 {
     using (var Context = new EcContext())
     {
         var product = Context.products.Find(ID);
         //Context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         Context.products.Remove(product);
         Context.SaveChanges();
     }
 }
示例#10
0
 public void DeleteCategory(int ID)
 {
     using (var Context = new EcContext())
     {
         var category = Context.Categories.Find(ID);
         //Context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         Context.Categories.Remove(category);
         Context.SaveChanges();
     }
 }