public void Insert(Customer pCustomer) { using (supermarket mySupermarket = new supermarket()) { mySupermarket.Customers.Add(pCustomer); mySupermarket.SaveChanges(); } }
public void Insert(Order pOrder) { using (supermarket mySupermarket = new supermarket()) { mySupermarket.Orders.Add(pOrder); mySupermarket.SaveChanges(); } }
public void Insert(Product pProduct) { using (supermarket mySupermarket = new supermarket()) { mySupermarket.Products.Add(pProduct); mySupermarket.SaveChanges(); } }
public List <Customer> SelectAll() { using (supermarket mySupermarket = new supermarket()) { List <Customer> allCustomers = mySupermarket.Customers.ToList(); return(allCustomers); } }
public List <Product> SelectAll() { using (supermarket mySupermarket = new supermarket()) { List <Product> allProducts = mySupermarket.Products.ToList(); return(allProducts); } }
public List <Customer> SelectByFrom(String Address) { using (supermarket mySupermarket = new supermarket()) { List <Customer> customerList = mySupermarket.Customers .Where(Customer => Customer.Address.Contains(Address)) .ToList(); return(customerList); } }
public Customer SelectById(int id) { using (supermarket mySupermarket = new supermarket()) { Customer customerFromId = mySupermarket.Customers .Where(Customer => Customer.CustomerId == id) .SingleOrDefault(); return(customerFromId); } }
public Order SelectById(int id) { using (supermarket mySupermarket = new supermarket()) { Order OrdersFromId = mySupermarket.Orders .Where(Order => Order.OrderId == id) .SingleOrDefault(); return(OrdersFromId); } }
public Product SelectById(int id) { using (supermarket mySupermarket = new supermarket()) { Product productsFromId = mySupermarket.Products .Where(Product => Product.ProductId == id) .SingleOrDefault(); return(productsFromId); } }
public void Delete(int pId) { using (supermarket mySupermarket = new supermarket()) { Customer customerDelete = mySupermarket.Customers .Where(Customer => Customer.CustomerId == pId) .SingleOrDefault(); if (customerDelete != null) { mySupermarket.Customers.Remove(customerDelete); mySupermarket.SaveChanges(); } } }
public void Delete(int pId) { using (supermarket mySupermarket = new supermarket()) { Order orderDelete = mySupermarket.Orders .Where(Order => Order.OrderId == pId) .SingleOrDefault(); if (orderDelete != null) { mySupermarket.Orders.Remove(orderDelete); mySupermarket.SaveChanges(); } } }
public void Delete(int pId) { using (supermarket mySupermarket = new supermarket()) { Product productDelete = mySupermarket.Products .Where(Product => Product.ProductId == pId) .SingleOrDefault(); if (productDelete != null) { mySupermarket.Products.Remove(productDelete); mySupermarket.SaveChanges(); } } }
static void Main(string[] args) { using (supermarket mySupermarket = new supermarket()) { Customer fistCustomer = new Customer(); fistCustomer.FistName = "Juan"; fistCustomer.LastName = "Perez"; fistCustomer.Address = "Alajuela"; fistCustomer.Telephone = 111111; mySupermarket.Customers.Add(fistCustomer); mySupermarket.SaveChanges(); } Console.WriteLine("Completed"); Console.ReadKey(); }
public void Update(Order pOrder) { using (supermarket mySupermarket = new supermarket()) { Order orderObj = mySupermarket.Orders .Where(Order => Order.OrderId == pOrder.OrderId) .SingleOrDefault(); if (orderObj != null) { orderObj.OrderDate = pOrder.OrderDate; mySupermarket.SaveChanges(); } } }
public void Update(Customer pCustomer) { using (supermarket mySupermarket = new supermarket()) { Customer customerObj = mySupermarket.Customers .Where(Customer => Customer.CustomerId == pCustomer.CustomerId) .SingleOrDefault(); if (customerObj != null) { customerObj.Address = pCustomer.Address; customerObj.FistName = pCustomer.FistName; customerObj.LastName = pCustomer.LastName; customerObj.Telephone = pCustomer.Telephone; mySupermarket.SaveChanges(); } } }
public void Update(Product pProduct) { using (supermarket mySupermarket = new supermarket()) { Product productObj = mySupermarket.Products .Where(Product => Product.ProductId == pProduct.ProductId) .SingleOrDefault(); if (productObj != null) { productObj.Name = pProduct.Name; productObj.Description = pProduct.Description; productObj.Price = pProduct.Price; productObj.Amount = productObj.Amount; mySupermarket.SaveChanges(); } } }