public List <CUSTOMERS> GetAllCustomers()
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         return(dbContext.CUSTOMERS.ToList());
     }
 }
Example #2
0
 public List <ORDERS_DETAIL> GetAllOrdersDetails()
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         return(dbContext.ORDERS_DETAIL.ToList());
     }
 }
Example #3
0
 public List <ORDERS> GetAllOrders()
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         return(dbContext.ORDERS.ToList());
     }
 }
 public List <PRODUCTS> GetAllProducts()
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         return(dbContext.PRODUCTS.ToList());
     }
 }
Example #5
0
 public bool InsertOrder(ORDERS newOrder)
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         dbContext.ORDERS.Add(newOrder);
         dbContext.SaveChanges();
     }
     return(true);
 }
 public bool InsertProduct(PRODUCTS newProduct)
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         dbContext.PRODUCTS.Add(newProduct);
         dbContext.SaveChanges();
     }
     return(true);
 }
 public bool InsertCustomer(CUSTOMERS newCustomer)
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         dbContext.CUSTOMERS.Add(newCustomer);
         dbContext.SaveChanges();
     }
     return(true);
 }
Example #8
0
 public bool InsertOrderDetail(ORDERS_DETAIL newOrderDetail)
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         dbContext.ORDERS_DETAIL.Add(newOrderDetail);
         dbContext.SaveChanges();
     }
     return(true);
 }
Example #9
0
        public ORDERS_DETAIL GetOrderDetailsById(int id)
        {
            var orderDetails = new ORDERS_DETAIL();

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                orderDetails = dbContext.ORDERS_DETAIL.FirstOrDefault(x => x.line_id == id);
            }
            return(orderDetails);
        }
Example #10
0
        public ORDERS GetOrderById(int id)
        {
            var order = new ORDERS();

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                order = dbContext.ORDERS.FirstOrDefault(x => x.order_id == id);
            }
            return(order);
        }
        public CUSTOMERS GetCustomerById(int id)
        {
            var customer = new CUSTOMERS();

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                customer = dbContext.CUSTOMERS.FirstOrDefault(x => x.client_id == id);
            }
            return(customer);
        }
        public PRODUCTS GetProductById(int id)
        {
            var product = new PRODUCTS();

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                product = dbContext.PRODUCTS.FirstOrDefault(x => x.product_id == id);
            }

            return(product);
        }
        public bool DeleteProduct(int id)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToDelete = dbContext.PRODUCTS.Find(id);
                dbContext.PRODUCTS.Remove(recordToDelete);
                dbContext.SaveChanges();
            }
            return(result);
        }
Example #14
0
        public bool DeleteOrderDetail(int id)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToDelete = dbContext.ORDERS_DETAIL.Find(id);
                dbContext.ORDERS_DETAIL.Remove(recordToDelete);
                dbContext.SaveChanges();
            }
            return(result);
        }
        public bool DeleteCustomer(int id)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToDelete = dbContext.CUSTOMERS.Find(id);
                dbContext.CUSTOMERS.Remove(recordToDelete);
                dbContext.SaveChanges();
            }
            return(result);
        }
Example #16
0
        public bool UpdateOrder(ORDERS editOrder)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToEdit = dbContext.ORDERS.FirstOrDefault(x => x.order_id == editOrder.order_id);
                recordToEdit.client_id   = editOrder.client_id;
                recordToEdit.order_date  = editOrder.order_date;
                recordToEdit.total_order = editOrder.total_order;
                recordToEdit.state       = editOrder.state;
            }
            return(result);
        }
Example #17
0
        public bool UpdateOrderDetail(ORDERS_DETAIL editOrderDetail)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToEdit = dbContext.ORDERS_DETAIL.FirstOrDefault(x => x.line_id == editOrderDetail.line_id);
                recordToEdit.order_id   = editOrderDetail.order_id;
                recordToEdit.product_id = editOrderDetail.product_id;
                recordToEdit.quantity   = editOrderDetail.quantity;
                recordToEdit.total_line = editOrderDetail.total_line;
            }
            return(result);
        }
        public bool UpdateProduct(PRODUCTS editProduct)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToEdit = dbContext.PRODUCTS.FirstOrDefault(x => x.product_id == editProduct.product_id);
                recordToEdit.product_code = editProduct.product_code;
                recordToEdit.product_name = editProduct.product_name;
                recordToEdit.cost_price   = editProduct.cost_price;
                recordToEdit.sale_price   = editProduct.sale_price;
                recordToEdit.state        = editProduct.state;
            }

            return(result);
        }
        public bool UpdateCustomer(CUSTOMERS editCustomer)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToEdit = dbContext.CUSTOMERS.FirstOrDefault(x => x.client_id == editCustomer.client_id);
                recordToEdit.document_type = editCustomer.document_type;
                recordToEdit.document_nro  = editCustomer.document_nro;
                recordToEdit.customer_name = editCustomer.customer_name;
                recordToEdit.address       = editCustomer.address;
                recordToEdit.email         = editCustomer.email;
                recordToEdit.state         = editCustomer.state;
            }
            return(result);
        }