public List <Customer> GetAllCustomer() { using (HAO_Entities db = new HAO_Entities()) { return((from c in db.Customers select c).ToList()); } }
public Customer GetCustomerById(int customerId) { using (HAO_Entities db = new HAO_Entities()) { return((from c in db.Customers where c.Id == customerId select c).FirstOrDefault()); } }
public Product GetProductById(int productId) { using (HAO_Entities db = new HAO_Entities()) { return((from p in db.Products where p.Id == productId select p).FirstOrDefault()); } }
public IEnumerable <Sales> GetSaleList() { List <Sales> sales = new List <Sales>(); using (HAO_Entities db = new HAO_Entities()) { var aa = (from ps in db.ProductSolds join c in db.Customers on ps.CustomerId equals c.Id join p in db.Products on ps.ProductId equals p.Id join s in db.Stores on ps.StoreId equals s.Id select(new { CustomerName = c.Name, ProductName = p.Name, ProductSold = ps.DateSold, ProductId = ps.Id }) ).ToList(); foreach (var sale in aa) { sales.Add(new Sales() { CustomerName = sale.CustomerName, ProductName = sale.ProductName, ProductSold = sale.ProductSold, ProductId = sale.ProductId }); } return(sales); } }
public List <Product> GetAllProduct() { using (HAO_Entities db = new HAO_Entities()) { return((from p in db.Products select p).ToList()); } }
public int AddProduct(Product product) { using (HAO_Entities db = new HAO_Entities()) { db.Products.Add(product); return(db.SaveChanges()); } }
public int ModifyCustomer(Customer customer) { using (HAO_Entities db = new HAO_Entities()) { db.Customers.Attach(customer); db.Entry <Customer>(customer).State = EntityState.Modified; return(db.SaveChanges()); } }
// add customer public int AddCustomer(Customer customer) { using (HAO_Entities db = new HAO_Entities()) { db.Customers.Add(customer); return(db.SaveChanges()); } }
public int ModidyProduct(Product product) { using (HAO_Entities db = new HAO_Entities()) { db.Products.Attach(product); db.Entry <Product>(product).State = EntityState.Modified; return(db.SaveChanges()); } }
public int DeleteCustomer(int customerId) { using (HAO_Entities db = new HAO_Entities()) { Customer c = new Customer() { Id = customerId }; db.Customers.Attach(c); db.Customers.Remove(c); return(db.SaveChanges()); } }
public int DeleteProduct(int productId) { using (HAO_Entities db = new HAO_Entities()) { Product p = new Product() { Id = productId }; db.Products.Attach(p); db.Products.Remove(p); return(db.SaveChanges()); } }