public void RefreshView()
        {
            Menu.Clear();
            Clients.Clear();
            ActiveOrders.Clear();
            CompletedOrders.Clear();
            ActiveDelivery.Clear();
            CompletedDeliveries.Clear();
            foreach (DishDTG dish in restaurantManager.GetMenu())
            {
                Menu.Add(new DishModel(dish));
            }

            foreach (ClientDTG client in restaurantManager.GetAllClients())
            {
                Clients.Add(new ClientModel(client));
            }
            foreach (OrderDTG order in restaurantManager.GetActiveOrders())
            {
                ActiveOrders.Add(new OrderModel(order));
            }
            foreach (OrderDTG order in restaurantManager.GetCompletedOrders())
            {
                CompletedOrders.Add(new OrderModel(order));
            }
            foreach (OrderDTG order in restaurantManager.GetActiveDeliveries())
            {
                ActiveDelivery.Add(new OrderModel(order));
            }
            foreach (OrderDTG order in restaurantManager.GetCompletedDeliveries())
            {
                CompletedDeliveries.Add(new OrderModel(order));
            }
        }
        public void RefreshView()
        {
            Menu.Clear();
            Clients.Clear();
            ActiveOrders.Clear();
            CompletedOrders.Clear();
            ActiveDelivery.Clear();
            CompletedDeliveries.Clear();
            foreach (Dish dish in restaurantManager.GetMenu())
            {
                Menu.Add(dish);
            }

            foreach (Client client in restaurantManager.GetAllClients())
            {
                Clients.Add(client);
            }
            foreach (Order order in restaurantManager.GetActiveOrders())
            {
                ActiveOrders.Add(order);
            }
            foreach (Order order in restaurantManager.GetCompletedOrders())
            {
                CompletedOrders.Add(order);
            }
            foreach (Order order in restaurantManager.GetActiveDeliveries())
            {
                ActiveDelivery.Add(order);
            }
            foreach (Order order in restaurantManager.GetCompletedDeliveries())
            {
                CompletedDeliveries.Add(order);
            }
        }
예제 #3
0
        public void CreateOrder(int currentOrderIndex, Client client, DateTime orderDate, List <DishDTG> dishes, bool delivery, Address deliveryAddress, DateTime deliveryEndTime)
        {
            List <Dish> dataDishes = new List <Dish>();

            foreach (DishDTG dtg in dishes)
            {
                int cat = Convert.ToInt32(dtg.Category);
                dataDishes.Add(new Dish(dtg.Id, dtg.Name, dtg.Description, null, (Category)cat, dtg.Price));
            }
            Order order = new Order(currentOrderIndex, client, orderDate, dataDishes, delivery, deliveryAddress, deliveryEndTime);

            ActiveOrders.Add(order);
        }
        public bool AddOrder(Order order, float?fadeOutTime)
        {
            if (order.TargetEntity == null)
            {
                DebugConsole.ThrowError("Attempted to add an order with no target entity to CrewManager!\n" + Environment.StackTrace.CleanupStackTrace());
                return(false);
            }

            // Ignore orders work a bit differently since the "unignore" order counters the "ignore" order
            var isUnignoreOrder = order.Identifier == "unignorethis";
            var orderPrefab     = !isUnignoreOrder ? order.Prefab : Order.GetPrefab("ignorethis");
            Pair <Order, float?> existingOrder = ActiveOrders.Find(o =>
                                                                   o.First.Prefab == orderPrefab && MatchesTarget(o.First.TargetEntity, order.TargetEntity) &&
                                                                   (o.First.TargetType != Order.OrderTargetType.WallSection || o.First.WallSectionIndex == order.WallSectionIndex));

            if (existingOrder != null)
            {
                if (!isUnignoreOrder)
                {
                    existingOrder.Second = fadeOutTime;
                    return(false);
                }
                else
                {
                    ActiveOrders.Remove(existingOrder);
                    return(true);
                }
            }
            else if (!isUnignoreOrder)
            {
                ActiveOrders.Add(new Pair <Order, float?>(order, fadeOutTime));
                return(true);
            }

            bool MatchesTarget(Entity existingTarget, Entity newTarget)
            {
                if (existingTarget == newTarget)
                {
                    return(true);
                }
                if (existingTarget is Hull existingHullTarget && newTarget is Hull newHullTarget)
                {
                    return(existingHullTarget.linkedTo.Contains(newHullTarget));
                }
                return(false);
            }

            return(false);
        }
예제 #5
0
 public NodeOrderService(IContainer container)
 {
     this.container = container;
     orderRoot      = container.GetById(OrderRootId);
     if (orderRoot == null)
     {
         container.RootNode.Add(new HiddenNode()
         {
             Id = OrderRootId
         });
     }
     else
     {
         foreach (var order in orderRoot.Children.OfType <NodeOrder>())
         {
             ActiveOrders.Add(order);
         }
     }
 }
예제 #6
0
        public bool AddOrder(Order order, float fadeOutTime)
        {
            if (order.TargetEntity == null)
            {
                DebugConsole.ThrowError("Attempted to add an order with no target entity to CrewManager!\n" + Environment.StackTrace.CleanupStackTrace());
                return(false);
            }

            Pair <Order, float> existingOrder = ActiveOrders.Find(o => o.First.Prefab == order.Prefab && o.First.TargetEntity == order.TargetEntity);

            if (existingOrder != null)
            {
                existingOrder.Second = fadeOutTime;
                return(false);
            }
            else
            {
                ActiveOrders.Add(new Pair <Order, float>(order, fadeOutTime));
                return(true);
            }
        }
예제 #7
0
 public static void AddOrder(Order newOrder)
 {
     ActiveOrders.Add(newOrder);
 }