Ejemplo n.º 1
0
 public Product GetProduct(int ID)
 {
     using (var context = new LBContext())
     {
         return(context.Products.Find(ID));
     }
 }
Ejemplo n.º 2
0
 public List <Product> GetProducts()
 {
     using (var context = new LBContext())
     {
         return(context.Products.ToList());
     }
 }
Ejemplo n.º 3
0
 public List <Category> GetCategories()
 {
     using (var context = new LBContext())
     {
         return(context.Categories.ToList());
     }
 }
Ejemplo n.º 4
0
 public Category GetCategory(int ID)
 {
     using (var context = new LBContext())
     {
         return(context.Categories.Find(ID));
     }
 }
Ejemplo n.º 5
0
 public void UpdateProduct(Product product)
 {
     using (var context = new LBContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void SaveProduct(Product product)
 {
     using (var context = new LBContext())
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public void UpdateCategory(Category category)
 {
     using (var context = new LBContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public void SaveCategory(Category category)
 {
     using (var context = new LBContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Ejemplo n.º 9
0
        public void DeleteProduct(int ID)
        {
            using (var context = new LBContext())
            {
                //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
                var product = context.Products.Find(ID);

                context.Products.Remove(product);

                context.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public void DeleteCategory(int ID)
        {
            using (var context = new LBContext())
            {
                //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
                var category = context.Categories.Find(ID);

                context.Categories.Remove(category);

                context.SaveChanges();
            }
        }