static public string GetSupplierNameByID(int id)
 {
     using (NorthWindEntities context = new NorthWindEntities())
     {
         try
         {
             return(context.Suppliers.Where(x => x.SupplierID == id).FirstOrDefault().CompanyName);
         }
         catch (EntityException entityExcp)
         {
             Logger.Write(entityExcp);
             return(null);
         }
     }
 }
Exemple #2
0
 public static List <Product> GetAll()
 {
     using (var context = new NorthWindEntities())
     {
         try
         {
             return(context.Products.ToList());
         }
         catch (EntityException entityExcp)
         {
             Logger.Write(entityExcp);
             return(null);
         }
     }
 }
Exemple #3
0
 public static Product GetById(int id)
 {
     using (var context = new NorthWindEntities())
     {
         try
         {
             return(context.Products.Where(x => x.ProductID == id).FirstOrDefault());
         }
         catch (EntityException entityExcp)
         {
             Logger.Write(entityExcp);
             return(null);
         }
     }
 }
Exemple #4
0
 static public Category GetByID(int id)
 {
     using (NorthWindEntities context = new NorthWindEntities())
     {
         try
         {
             return(context.Categories.Where(x => x.CategoryID == id).FirstOrDefault());
         }
         catch (EntityException entityExcp)
         {
             Logger.Write(entityExcp);
             return(null);
         }
     }
 }
Exemple #5
0
 static public List <Category> GetAll()
 {
     using (NorthWindEntities context = new NorthWindEntities())
     {
         try
         {
             return(context.Categories.ToList());
         }
         catch (EntityException entityExcp)
         {
             Logger.Write(entityExcp);
             return(null);
         }
     }
 }
Exemple #6
0
 public static void UpdateProduct(Product product)
 {
     using (var context = new NorthWindEntities())
     {
         try
         {
             context.Entry(product).State = EntityState.Modified;
             context.SaveChanges();
         }
         catch (EntityException entityExcp)
         {
             Logger.Write(entityExcp);
             return;
         }
     }
 }