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); } } }
public static List <Product> GetAll() { using (var context = new NorthWindEntities()) { try { return(context.Products.ToList()); } catch (EntityException entityExcp) { Logger.Write(entityExcp); return(null); } } }
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); } } }
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); } } }
static public List <Category> GetAll() { using (NorthWindEntities context = new NorthWindEntities()) { try { return(context.Categories.ToList()); } catch (EntityException entityExcp) { Logger.Write(entityExcp); return(null); } } }
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; } } }