コード例 #1
0
        public static void RemoveItemFromOrder(int tblId, string itemName)
        {
            var tableOrder = GetTableOrder(tblId);

            if (tableOrder != null)
            {
                foreach (var order in PendingOrders)
                {
                    if (order.Table == tblId)
                    {
                        var orderItem = order.OrderItems
                                        .FirstOrDefault(x => x.Name.Equals(itemName));
                        if (orderItem != null)
                        {
                            order.OrderItems.Remove(orderItem);
                        }
                    }
                }

                if (tableOrder.OrderItems.Count == 0)
                {
                    RemoveOrder(tblId);
                }
            }

            XmlStateService.SaveOrdersState(PendingOrders);
        }
コード例 #2
0
        public static void RemoveOrder(int tblId)
        {
            var orderToRemove = PendingOrders.FirstOrDefault(x => x.Table == tblId);

            PendingOrders.Remove(orderToRemove);

            XmlStateService.SaveOrdersState(PendingOrders);
        }
コード例 #3
0
        public static void MoveOrder(int fromTable, int toTable)
        {
            var orderToMove = PendingOrders.FirstOrDefault(x => x.Table == fromTable);

            if (orderToMove != null)
            {
                PendingOrders.Remove(orderToMove);

                orderToMove.Table = toTable;
                PendingOrders.Add(orderToMove);

                XmlStateService.SaveOrdersState(PendingOrders);
            }
        }
コード例 #4
0
        public static void SetupOrder(int tblId, OrderItemDto orderItem)
        {
            var tableOrder = GetTableOrder(tblId);

            if (tableOrder != null)
            {
                var itemExists = tableOrder.OrderItems.FirstOrDefault(x => x.Id == orderItem.Id);
                if (itemExists != null)
                {
                    foreach (var item in tableOrder.OrderItems)
                    {
                        if (item.Id == orderItem.Id)
                        {
                            item.Quantity += orderItem.Quantity;
                        }
                    }
                }
                else
                {
                    foreach (var order in PendingOrders)
                    {
                        if (order.Table == tblId)
                        {
                            order.OrderItems.Add(orderItem);
                        }
                    }
                }

                var itemsAmount = tableOrder.OrderItems.Sum(x => x.Price * x.Quantity);
                tableOrder.TotalAmount = itemsAmount;
            }
            else
            {
                PendingOrders.Add(new OrderDto
                {
                    Table      = tblId,
                    OrderItems = new List <OrderItemDto> {
                        orderItem
                    },
                    DateCreated = DateTime.Now,
                    TotalAmount = orderItem.Price * orderItem.Quantity
                });
            }

            XmlStateService.SaveOrdersState(PendingOrders);
        }
コード例 #5
0
        public static void FinalizeOrder(int tblId)
        {
            var tableOrder      = GetTableOrder(tblId);
            var tableOrderItems = tableOrder.OrderItems;

            int orderCreatedId = S.OrderService.Create(tableOrder);

            foreach (var item in tableOrderItems)
            {
                S.OrderItemService.Create(new OrderItemDto
                {
                    Id       = item.Id,
                    Name     = item.Name,
                    Price    = item.Price,
                    OrderId  = orderCreatedId,
                    Quantity = item.Quantity
                });
            }

            PendingOrders.Remove(tableOrder);
            XmlStateService.SaveOrdersState(PendingOrders);
        }