Exemplo n.º 1
0
 public string GetProductCategoryName(int id)
 {
     using (OrderEntities context = new OrderEntities())
     {
         return(context.ProductCategories.Where(p => p.ID == id).FirstOrDefault().Name);
     }
 }
Exemplo n.º 2
0
 public List <ProductCategory> GetAllProductCategory()
 {
     using (OrderEntities context = new OrderEntities())
     {
         context.Configuration.LazyLoadingEnabled = false;
         System.Data.Entity.DbSet <ProductCategory> productCates = context.ProductCategories;
         return(productCates.ToList());
     }
 }
Exemplo n.º 3
0
 public void DeleteProductCategory(int id)
 {
     using (OrderEntities context = new OrderEntities())
     {
         ProductCategory obj = context.ProductCategories.Where(p => p.ID == id).FirstOrDefault();
         context.ProductCategories.Remove(obj);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void UpdateProductCategory(int id, string name)
 {
     using (OrderEntities context = new OrderEntities())
     {
         ProductCategory obj = context.ProductCategories.Where(p => p.ID == id).FirstOrDefault();
         if (obj != null)
         {
             obj.Name = name;
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public int AddProductCategory(string name)
 {
     using (OrderEntities context = new OrderEntities())
     {
         ProductCategory obj = new ProductCategory()
         {
             Name = name
         };
         context.ProductCategories.Add(obj);
         context.SaveChanges();
         return(obj.ID);
     }
 }