示例#1
0
 public string GetProductCategoryName(int id)
 {
     using (OrderEntities context = new OrderEntities())
     {
         return(context.ProductCategories.Where(p => p.ID == id).FirstOrDefault().Name);
     }
 }
示例#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());
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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);
     }
 }