Exemple #1
0
        //gets order lines of current order
        public List <OrderManagement.DAL.OrderLinesTable> GetOrderLines(OrdersTable order)
        {
            using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
            {
                List <OrderManagement.DAL.OrderLinesTable> orderLines = new List <OrderManagement.DAL.OrderLinesTable>();

                //return orderLines.Where(c => c.OrdersTable == order).ToList();

                foreach (var c in ct.OrderLinesTable.Where(c => c.OrdersTable.OrderNumber == order.OrderNumber))
                {
                    //LibraryClasses.UserType userType = new LibraryClasses.UserType()
                    OrderManagement.DAL.OrderLinesTable orderLine = new OrderManagement.DAL.OrderLinesTable()
                    {
                        Id              = c.Id,
                        ProductID       = c.ProductID,
                        QuantityOrdered = c.QuantityOrdered,
                        SellingPrice    = c.SellingPrice,
                        OrderNumber     = c.OrderNumber,
                        TotalForItem    = c.TotalForItem
                    };
                    orderLines.Add(orderLine);
                }
                return(orderLines);
            }
        }
Exemple #2
0
        //deletes order from database
        public void DeleteOrder(OrderManagement.DAL.OrdersTable order)
        {
            using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
            {
                OrdersTable or = ct.OrdersTable.First(t => t.OrderNumber == order.OrderNumber);

                //OrdersTable ord = new OrdersTable() { OrderNumber = order.OrderNumber };
                ct.Entry(or).State = System.Data.EntityState.Deleted;
                ct.SaveChanges();
            }
        }