Exemplo n.º 1
0
 public void Insert(Customer pCustomer)
 {
     using (supermarket mySupermarket = new supermarket())
     {
         mySupermarket.Customers.Add(pCustomer);
         mySupermarket.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void Insert(Order pOrder)
 {
     using (supermarket mySupermarket = new supermarket())
     {
         mySupermarket.Orders.Add(pOrder);
         mySupermarket.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void Insert(Product pProduct)
 {
     using (supermarket mySupermarket = new supermarket())
     {
         mySupermarket.Products.Add(pProduct);
         mySupermarket.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public List <Customer> SelectAll()
        {
            using (supermarket mySupermarket = new supermarket())
            {
                List <Customer> allCustomers = mySupermarket.Customers.ToList();

                return(allCustomers);
            }
        }
Exemplo n.º 5
0
        public List <Product> SelectAll()
        {
            using (supermarket mySupermarket = new supermarket())
            {
                List <Product> allProducts = mySupermarket.Products.ToList();

                return(allProducts);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        public Customer SelectById(int id)
        {
            using (supermarket mySupermarket = new supermarket())
            {
                Customer customerFromId = mySupermarket.Customers

                                          .Where(Customer => Customer.CustomerId == id)
                                          .SingleOrDefault();

                return(customerFromId);
            }
        }
Exemplo n.º 8
0
        public Order SelectById(int id)
        {
            using (supermarket mySupermarket = new supermarket())
            {
                Order OrdersFromId = mySupermarket.Orders

                                     .Where(Order => Order.OrderId == id)
                                     .SingleOrDefault();

                return(OrdersFromId);
            }
        }
Exemplo n.º 9
0
        public Product SelectById(int id)
        {
            using (supermarket mySupermarket = new supermarket())
            {
                Product productsFromId = mySupermarket.Products

                                         .Where(Product => Product.ProductId == id)
                                         .SingleOrDefault();

                return(productsFromId);
            }
        }
Exemplo n.º 10
0
        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();
                }
            }
        }
Exemplo n.º 11
0
        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();
                }
            }
        }
Exemplo n.º 12
0
        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();
                }
            }
        }
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
0
        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();
                }
            }
        }
Exemplo n.º 15
0
        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();
                }
            }
        }
Exemplo n.º 16
0
        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();
                }
            }
        }