Example #1
0
 public Product GetProducts(int ID)
 {
     using (var Context = new EcContext())
     {
         return(Context.products.Find(ID));
     }
 }
Example #2
0
 public List <Product> GetProducts()
 {
     using (var Context = new EcContext())
     {
         return(Context.products.ToList());
     }
 }
Example #3
0
 public List <Category> GetCategories()
 {
     using (var Context = new EcContext())
     {
         return(Context.Categories.ToList());
     }
 }
Example #4
0
 public Category GetCategories(int ID)
 {
     using (var Context = new EcContext())
     {
         return(Context.Categories.Find(ID));
     }
 }
Example #5
0
 public void UpdateProduct(Product product)
 {
     using (var Context = new EcContext())
     {
         Context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         Context.SaveChanges();
     }
 }
Example #6
0
 public void SaveProduct(Product product)
 {
     using (var Context = new EcContext())
     {
         Context.products.Add(product);
         Context.SaveChanges();
     }
 }
Example #7
0
 public void UpdateCategory(Category category)
 {
     using (var Context = new EcContext())
     {
         Context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         Context.SaveChanges();
     }
 }
Example #8
0
 public void SaveCategory(Category category)
 {
     using (var Context = new EcContext())
     {
         Context.Categories.Add(category);
         Context.SaveChanges();
     }
 }
Example #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();
     }
 }
Example #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();
     }
 }